| rnd HLD group |
|---|
| Public |
| Spectator |
| rnd HLD |
|---|
| Finished |
Initially, you are given a tree consisting of a single root vertex numbered $$$1$$$. This vertex contains an integer $$$a_1$$$.
You have to process a sequence of queries, each of which is one of the following three types. Note that the queries must be processed online. The parameters given in the input are encrypted.
Let $$$last$$$ denote the answer to the most recent query of type $$$3$$$. Initially, $$$last = 0$$$. If a type $$$3$$$ query does not find a suitable value (i.e., the answer is -1), then $$$last$$$ becomes $$$0$$$.
The parameters of each query are decoded using the following formulas, where $$$V$$$ is the current number of vertices in the tree before processing the query:
Here, $$$\oplus$$$ denotes the bitwise exclusive OR operation (XOR in C++).
The first line of the input contains two integers $$$a_1$$$ and $$$q$$$ ($$$1 \le a_1 \le 10^9$$$, $$$1 \le q \le 5 \cdot 10^5$$$) — the value written in the root vertex and the number of queries.
The next $$$q$$$ lines contain descriptions of the queries in the encrypted format described in the problem statement.
It is guaranteed that after decryption, all parameters will be valid: $$$1 \le p, v, u \le V$$$, and all values of $$$a$$$ and $$$x$$$ will be in the range from $$$1$$$ to $$$10^9$$$.
For each query of the third type, print a single integer in a separate line — the minimum value on the path that is strictly greater than the decrypted $$$x$$$. If no such number exists on the path, print '-1'.
5 61 0 11 1 73 0 2 22 4 63 5 7 73 4 6 3
5 4 -1
| Name |
|---|


