1044_D. Deduction Queries_28828
There is an array a of 2^{30} integers, indexed from 0 to 2^{30}-1. Initially, you know that 0 ≤ a_i < 2^{30} (0 ≤ i < 2^{30}), but you do not know any of the values. Your task is to process queries of two types:

  * 1 l r x: You are informed that the bitwise xor of the subarray [l, r] (ends inclusive) is equal to x. That is, a_l ⊕ a_{l+1} ⊕ … ⊕ a_{r-1} ⊕ a_r = x, where ⊕ is the bitwise xor operator. In some cases, the received update contradicts past updates. In this case, you should ignore the contradicting update (the current update).
  * 2 l r: You are asked to output the bitwise xor of the subarray [l, r] (ends inclusive). If it is still impossible to know this value, considering all past updates, then output -1.



Note that the queries are encoded. That is, you need to write an online solution.

Input

The first line contains a single integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries.

Each of the next q lines describes a query. It contains one integer t (1 ≤ t ≤ 2) — the type of query.

The given queries will be encoded in the following way: let last be the answer to the last query of the second type that you have answered (initially, last = 0). If the last answer was -1, set last = 1.

  * If t = 1, three integers follow, l', r', and x' (0 ≤ l', r', x' < 2^{30}), meaning that you got an update. First, do the following: l = l' ⊕ last, r = r' ⊕ last, x = x' ⊕ last 

and, if l > r, swap l and r.

This means you got an update that the bitwise xor of the subarray [l, r] is equal to x (notice that you need to ignore updates that contradict previous updates).

  * If t = 2, two integers follow, l' and r' (0 ≤ l', r' < 2^{30}), meaning that you got a query. First, do the following: l = l' ⊕ last, r = r' ⊕ last 

and, if l > r, swap l and r.

For the given query, you need to print the bitwise xor of the subarray [l, r]. If it is impossible to know, print -1. Don't forget to change the value of last.




It is guaranteed there will be at least one query of the second type.

Output

After every query of the second type, output the bitwise xor of the given subarray or -1 if it is still impossible to know.

Examples

Input

12
2 1 2
2 1 1073741822
1 0 3 4
2 0 0
2 3 3
2 0 3
1 6 7 3
2 4 4
1 0 2 1
2 0 0
2 4 4
2 0 0


Output

-1
-1
-1
-1
5
-1
6
3
5


Input

4
1 5 5 9
1 6 6 5
1 6 5 10
2 6 5


Output

12

Note

In the first example, the real queries (without being encoded) are:

  * 12
  * 2 1 2
  * 2 0 1073741823
  * 1 1 2 5
  * 2 1 1
  * 2 2 2
  * 2 1 2
  * 1 2 3 6
  * 2 1 1
  * 1 1 3 0
  * 2 1 1
  * 2 2 2
  * 2 3 3


  * The answers for the first two queries are -1 because we don't have any such information on the array initially. 
  * The first update tells us a_1 ⊕ a_2 = 5. Note that we still can't be certain about the values a_1 or a_2 independently (for example, it could be that a_1 = 1, a_2 = 4, and also a_1 = 3, a_2 = 6). 
  * After we receive all three updates, we have enough information to deduce a_1, a_2, a_3 independently. 



In the second example, notice that after the first two updates we already know that a_5 ⊕ a_6 = 12, so the third update is contradicting, and we ignore it.
import os
import sys
from atexit import register
from io import BytesIO

sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))

input = lambda: sys.stdin.readline().rstrip('\r\n')
q=int(input())
home=[]
last=0
parents={}
for i in xrange(q):
    a=list(map(int,input().split()))
    for i in xrange(len(a)-1):
        a[i+1]=a[i+1]^last
    start,end=min(a[1],a[2])-1,max(a[1],a[2])
    x,y=start in parents,end in parents
    if x:
        if y:
            xor=parents[start][1]
            daddy=parents[start][0]
            child=start
            long=[]
            while True:
                if child==daddy:
                    break
                long.append((child,parents[child][1]))
                xor=xor^parents[daddy][1]
                child=daddy
                daddy=parents[daddy][0]
            xor3=0
            for guy in long[::-1]:
                xor3^=guy[1]
                parents[guy[0]]=(daddy,xor3)
            xor1=parents[end][1]
            daddy1=parents[end][0]
            child1=end
            long=[]
            while True:
                if child1==daddy1:
                    break
                long.append((child1,parents[child1][1]))
                xor1=xor1^parents[daddy1][1]
                child1=daddy1
                daddy1=parents[daddy1][0]
            xor2=0
            for guy in long[::-1]:
                xor2^=guy[1]
                parents[guy[0]]=(daddy1,xor2)
            if a[0]==2:
                if daddy==daddy1:
                    last=xor^xor1
                    print(last)
                else:
                    print(-1)
                    last=1
            else:
                if daddy!=daddy1:
                    parents[daddy]=(parents[daddy1][0],xor1^xor^a[3])
        else:
            if a[0]==2:
                print(-1)
                last=1
            else:
                parents[end]=(parents[start][0],a[3]^parents[start][1])
    else:
        if y:
            if a[0]==2:
                print(-1)
                last=1
            else:
                parents[start]=(parents[end][0],a[3]^parents[end][1])
        else:
            if a[0]==2:
                print(-1)
                last=1
            else:
                home.append(start)
                parents[end]=(start,a[3])
                parents[start]=(start,0)
4
1 5 5 9
1 6 6 5
1 6 5 10
2 6 5
 12
2 1 2
2 1 1073741822
1 0 3 4
2 0 0
2 3 3
2 0 3
1 6 7 3
2 4 4
1 0 2 1
2 0 0
2 4 4
2 0 0
 9
1 0 0 1073741823
1 1 1 987654321
1 2 2 123456789
2 0 0
2 1073741822 1073741822
2 987654323 987654323
2 123456788 123456789
2 86087500 86087503
2 1032168868 1032168870
 1
2 2 2
 9
1 0 0 1073741823
1 0 1 987654321
1 2 2 123456789
2 0 0
2 1073741822 1073741822
2 987654323 987654323
2 123456788 123456789
2 86087500 86087503
2 1032168868 1032168870
 4
1 5 5 13
1 6 6 5
1 6 5 10
2 6 5
 12
2 1 2
2 1 1073741822
1 0 3 5
2 0 0
2 3 3
2 0 3
1 6 7 3
2 4 4
1 0 2 1
2 0 0
2 4 4
2 0 0
 9
1 0 0 1073741823
1 0 1 987654321
1 2 2 123456789
2 0 0
2 2035401420 1073741822
2 987654323 987654323
2 123456788 123456789
2 86087500 86087503
2 1032168868 1032168870
 12
2 1 1
2 1 1073741822
1 0 3 5
2 0 0
2 3 3
2 0 3
1 6 7 2
2 4 4
1 0 2 1
2 0 0
2 4 4
2 0 0
 9
1 0 0 1073741823
1 1 1 987654321
1 2 2 123456789
2 0 0
2 1073741822 1073741822
2 987654323 987654323
2 123456788 123456789
2 86087500 86087503
2 1032168868 1983893774
 4
1 4 5 9
1 6 6 5
1 6 5 10
2 6 5
 12
2 1 1
2 1 1073741822
1 0 3 4
2 0 0
2 3 3
2 0 3
1 6 7 3
2 4 4
1 0 2 1
2 0 0
2 4 4
2 0 0
 9
1 0 -1 1073741823
1 0 1 987654321
1 2 2 123456789
2 0 0
2 2035401420 1073741822
2 987654323 987654323
2 123456788 123456789
2 86087500 86087503
2 1032168868 1032168870
 12
2 1 1
2 1 1073741822
1 0 3 5
2 0 0
2 3 3
2 0 1
1 6 7 3
2 4 4
1 0 2 1
2 0 0
2 4 4
2 0 0
 9
1 0 0 1073741823
1 1 1 987654321
1 2 2 123456789
2 0 0
2 1073741822 1073741822
2 987654323 987654323
2 123456788 25564279
2 86087500 86087503
2 1032168868 1983893774
 4
1 4 5 9
1 6 6 5
1 6 4 10
2 6 5
 9
1 0 0 1073741823
1 1 1 987654321
1 2 2 123456789
2 0 0
2 1073741822 1073741822
2 987654323 801370996
2 123456788 25564279
2 86087500 86087503
2 1032168868 1983893774
 9
1 0 1 1073741823
1 1 1 987654321
1 2 2 123456789
2 0 0
2 1073741822 1073741822
2 987654323 801370996
2 123456788 25564279
2 86087500 86087503
2 1032168868 1983893774
 12
2 1 1
2 1 1073741822
1 0 3 5
2 2 0
2 3 3
2 0 3
1 6 7 2
2 1 4
1 0 2 0
2 0 0
2 4 4
2 0 0
 12
2 1 1
2 1 1073741822
1 0 3 5
2 3 0
2 3 3
2 0 3
1 6 7 2
2 0 4
1 0 2 0
2 0 0
2 4 4
2 0 1
 12
2 1 1
2 1 1073741822
1 0 3 5
2 3 0
2 3 3
2 0 3
1 6 7 2
2 0 4
1 0 2 0
2 0 1
2 4 4
2 0 1
 12
2 1 1
2 1 1073741822
1 0 3 5
2 0 0
2 3 3
2 0 3
1 6 7 3
2 4 4
1 0 2 1
2 0 0
2 4 4
2 0 0
 9
1 0 0 1073741823
1 0 1 987654321
1 2 2 123456789
2 0 0
2 1073741822 1073741822
2 987654323 1378386082
2 123456788 123456789
2 86087500 86087503
2 1032168868 1032168870
 4
1 5 5 13
1 6 6 5
1 6 2 10
2 6 5
 12
2 1 2
2 1 1073741822
1 0 3 5
2 -1 0
2 3 3
2 0 3
1 6 7 3
2 4 4
1 0 2 1
2 0 0
2 4 4
2 0 0
 12
2 1 1
2 1 1073741822
1 0 3 5
2 0 0
2 3 3
2 0 3
1 6 7 2
2 1 4
1 0 2 1
2 0 0
2 4 4
2 0 0
 9
1 0 0 1073741823
1 0 1 987654321
1 2 4 123456789
2 0 0
2 1073741822 1073741822
2 987654323 1378386082
2 123456788 123456789
2 86087500 86087503
2 1032168868 1032168870
 12
2 1 2
2 1 1073741822
1 1 3 5
2 -1 0
2 3 3
2 0 3
1 6 7 3
2 4 4
1 0 2 1
2 0 0
2 4 4
2 0 0
 9
1 0 -1 131849169
1 0 1 987654321
1 2 2 123456789
2 0 0
2 2035401420 1073741822
2 987654323 987654323
2 123456788 123456789
2 86087500 86087503
2 1032168868 1032168870
 12
2 1 1
2 1 1073741822
1 0 3 5
2 1 0
2 3 3
2 0 3
1 6 7 2
2 1 4
1 0 2 1
2 0 0
2 4 4
2 0 0
 4
1 4 5 9
1 6 6 5
1 6 4 10
2 6 3
 12
2 1 2
2 1 1073741822
1 1 3 5
2 -1 0
2 3 3
2 0 3
1 6 7 3
2 4 6
1 0 2 1
2 0 0
2 4 4
2 0 0
 9
1 0 -1 68356273
1 0 1 987654321
1 2 2 123456789
2 0 0
2 2035401420 1073741822
2 987654323 987654323
2 123456788 123456789
2 86087500 86087503
2 1032168868 1032168870
 12
2 1 1
2 1 1073741822
1 0 3 5
2 2 0
2 3 3
2 0 3
1 6 7 2
2 1 4
1 0 2 1
2 0 0
2 4 4
2 0 0
 4
1 4 5 9
1 6 6 9
1 6 4 10
2 6 3
 12
2 1 2
2 1 1073741822
1 1 3 5
2 -1 0
2 3 3
2 0 3
1 6 7 3
2 4 6
1 0 2 1
2 0 0
2 4 4
2 0 -1
 9
1 0 -1 68356273
1 0 1 987654321
1 2 2 123456789
2 0 0
2 2035401420 1073741822
2 987654323 987654323
2 123456788 123456789
2 86087500 86087503
2 1865935547 1032168870
 9
1 0 1 1073741823
1 1 1 987654321
1 2 2 123456789
2 0 0
2 1073741822 1073741822
2 1698835639 801370996
2 123456788 25564279
2 86087500 86087503
2 1032168868 1983893774
 4
1 4 5 9
1 6 6 9
1 6 4 19
2 6 3
 12
2 1 2
2 1 1073741822
1 1 3 5
2 -1 0
2 3 5
2 0 3
1 6 7 3
2 4 6
1 0 2 1
2 0 0
2 4 4
2 0 -1
 12
2 1 1
2 1 1073741822
1 0 3 5
2 2 0
2 3 3
2 0 3
1 6 7 2
2 1 4
1 0 2 0
2 0 0
2 4 4
2 0 1
 9
1 -1 1 1073741823
1 1 1 987654321
1 2 2 123456789
2 0 0
2 1073741822 1073741822
2 1698835639 801370996
2 123456788 25564279
2 86087500 86087503
2 1032168868 1983893774
 4
1 4 5 9
1 6 6 15
1 6 4 19
2 6 3
 12
2 1 2
2 1 1073741822
1 1 3 10
2 -1 0
2 3 5
2 0 3
1 6 7 3
2 4 6
1 0 2 1
2 0 0
2 4 4
2 0 -1
 12
2 1 1
2 1 1073741822
1 0 3 5
2 2 0
2 3 3
2 0 3
1 6 7 2
2 0 4
1 0 2 0
2 0 0
2 4 4
2 0 1
 4
1 4 5 9
1 6 6 15
1 6 4 19
2 11 3
 12
2 1 2
2 1 1073741822
1 1 3 10
2 -1 0
2 3 5
2 0 3
1 6 7 3
2 4 6
1 0 2 1
2 0 -1
2 4 4
2 0 -1
 4
1 4 5 9
1 6 6 15
1 6 4 19
2 11 5
 12
2 1 1
2 1 1073741822
1 0 3 5
2 3 0
2 0 3
2 0 3
1 6 7 2
2 0 4
1 0 2 0
2 0 1
2 4 4
2 0 1

12
 -1
-1
-1
-1
5
-1
6
3
5
 1073741823
987654321
123456789
86087502
1032168868
41572955
 -1
 1073741823
86087502
-1
-1
-1
-1
 8
 -1
-1
-1
-1
4
-1
7
4
-1
 1073741823
-1
-1
-1
-1
-1
 -1
-1
-1
-1
4
-1
6
2
2
 1073741823
987654321
123456789
86087502
1032168868
-1
 10
 -1
-1
-1
-1
5
-1
6
3
5
 -1
-1
-1
-1
-1
-1
 -1
-1
-1
-1
-1
-1
-1
-1
-1
 1073741823
987654321
123456789
-1
-1
-1
 -1
 1073741823
987654321
-1
-1
-1
-1
 86087502
-1
-1
-1
-1
-1
 -1
-1
-1
-1
4
-1
7
5
-1
 -1
-1
4
-1
4
-1
7
5
-1
 -1
-1
4
-1
4
-1
-1
-1
-1
 -1
-1
-1
-1
4
-1
7
4
-1
 1073741823
86087502
-1
-1
-1
-1
 8
 -1
-1
-1
-1
4
-1
7
4
-1
 -1
-1
-1
-1
4
-1
6
2
2
 1073741823
86087502
-1
-1
-1
-1
 -1
-1
-1
-1
-1
-1
-1
-1
-1
 -1
-1
-1
-1
-1
-1
 -1
-1
-1
-1
4
-1
6
2
2
 -1
 -1
-1
-1
-1
-1
-1
-1
-1
-1
 -1
-1
-1
-1
-1
-1
 -1
-1
-1
-1
4
-1
6
2
2
 -1
 -1
-1
-1
-1
-1
-1
-1
-1
-1
 -1
-1
-1
-1
-1
-1
 86087502
-1
-1
-1
-1
-1
 -1
 -1
-1
-1
-1
-1
-1
-1
-1
-1
 -1
-1
-1
-1
4
-1
7
5
-1
 -1
-1
-1
-1
-1
-1
 -1
 -1
-1
-1
-1
-1
-1
-1
-1
-1
 -1
-1
-1
-1
4
-1
7
5
-1
 -1
 -1
-1
-1
-1
-1
-1
-1
-1
-1
 -1
 -1
-1
4
-1
4
-1
-1
-1
-1
