#include <bits/stdc++.h>   using namespace std;   int N, T, L, R, X, H;   unordered_map<int, int> siz;   unordered_map<int, pair<int, int> > par;   pair<int, int> find(int now) {     if (par.count(now)) {       pair<int, int> a, b;       a = par[now];       b = find(a.first);       return {b.first, a.second ^ b.second};     }     return {now, 0};   }   int getsize(int now) {     if (!siz.count(now)) {       siz[now] = 1;     }     return siz[now];   }   void merge(int x, int y, int z) {     pair<int, int> a, b;     a = find(x);     b = find(y);     if (a.first == b.first) {       return;     }     if (getsize(a.first) > getsize(b.first)) {       par[b.first] = {a.first, z ^ a.second ^ b.second};       siz[a.first] += siz[b.first];     } else {       par[a.first] = {b.first, z ^ a.second ^ b.second};       siz[b.first] += siz[a.first];     }     return;   }   int ans(int x, int y) {     pair<int, int> a, b;     a = find(x);     b = find(y);     if (a.first != b.first) {       return -1;     }     return a.second ^ b.second;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> N;     for (int i = 0; i < N; i++) {       cin >> T >> L >> R;       L ^= H;       R ^= H;       if (L > R) {         swap(L, R);       }       if (T == 1) {         cin >> X;         X ^= H;         merge(L - 1, R, X);       } else {         H = ans(L - 1, R);         cout << H <<   n ;         if (H == -1) {           H = 1;         }       }     }     return 0;   }   