问题 E: Star Wars

内存限制:256 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

链接:https://ac.nowcoder.com/acm/contest/57361/E
来源:牛客网
The new round of Star Wars has begun.

In this round of Star Wars, our side has established n bases in the universe. At the beginning of the war, all bases had zero troops and there were no wormholes. A wormhole connects two different bases and can be bidirectional.

You need to help the commander-in-chief write a program to answer some questions based on the battlefield situation.

输入格式

We use last\text{last}last to represent the answer of the last 444 operation and initialize last=0\text{last}=0last=0.
The first line contains two integers nnn (1≤n≤3×1051\le n\le 3\times10^51n3×105) and qqq (1≤q≤3×1051\le q\le 3\times10^51q3×105), which represent the number of bases and the number of instructions that the commander-in-chief will give you.
Next qqq lines, each line contains one instruction. There are four types of instructions:
- `1 x y` Our side added a wormhole connecting xxx and yyy.
- `2 x y` The enemy destroyed a wormhole connecting xxx and yyy. It is guaranteed that this wormhole existed before this operation.
- `3 x c` base xxx increased ccc (0≤c≤1090\le c\le 10^90c109) troops.
- `4 x` Find the sum of troops that can be reached from base xxx through at most one wormhole.
You need to transform the input x,y,cx,y,cx,y,c into x⊕(last mod 230),y⊕(last mod 230),c⊕(last mod 230)x\oplus (\text{last}\ \text{mod}\ 2^{30}),y\oplus (\text{last}\ \text{mod}\ 2^{30}),c\oplus (\text{last}\ \text{mod}\ 2^{30})x(last mod 230),y(last mod 230),c(last mod 230) to get the real data, where ⊕\oplus means binary XOR.

输出格式

For each 4 operation, output a line representing the answer.

输入样例 复制

5 10
1 5 1
3 5 10
3 4 100
1 1 4
4 1
2 111 107
1 106 107
3 106 10
4 107
4 214

输出样例 复制

110
210
210