#include <bits/stdc++.h>   using namespace std;   template <class T>   using VV = vector<vector<T>>;   template <class T>   inline T SMIN(T& a, const T b) {     return a = (a > b) ? b : a;   }   template <class T>   inline T SMAX(T& a, const T b) {     return a = (a < b) ? b : a;   }   template <class Iter>   void dumpc(Iter begin, Iter end) {     if (false) {       for (; begin != end; ++begin) {         cerr << *begin <<  , ;       }       cerr << endl;     }   }   int Q;   map<int, int> comp;   int getid(int a) {     if (comp.count(a)) return comp[a];     comp[a] = int((comp).size());     return comp[a];   }   struct UF {    public:     int groupNum;     vector<int> X;     UF(int N) {       uf = vector<int>(N);       rank = vector<int>(N);       X = vector<int>(N);       for (int i = 0; i < N; ++i) uf[i] = i, rank[i] = 0;       groupNum = N;     }     pair<int, int> find(int v) {       int cur = 0;       while (uf[v] != v) {         cur ^= X[v];         v = uf[v];       }       return {v, cur};     }     bool same(int x, int y) { return find(x) == find(y); }     void unite(int x, int y, int z) {       auto px = find(x);       auto py = find(y);       if (px.first == py.first) return;       groupNum--;       x = px.first, y = py.first;       z = px.second ^ py.second ^ z;       if (rank[x] == rank[y]) {         uf[x] = y;         X[x] = z;         rank[y]++;         return;       }       if (rank[x] < rank[y]) {         uf[x] = y;         X[x] = z;       } else {         uf[y] = x;         X[y] = z;         if (rank[x] == rank[y]) ++rank[x];       }     }       private:     vector<int> rank;     vector<int> uf;   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> Q;     UF uf(2 * Q + 10);     int last = 0;     while (Q--) {       int t, l, r;       cin >> t >> l >> r;       l ^= last, r ^= last;       if (l > r) swap(l, r);       ++r;       if (false) {         cerr <<  l               <<   =   << (l) <<  ,                <<  r               <<   =   << (r) <<  ,                <<  getid(l)               <<   =   << (getid(l)) <<  ,                <<  getid(r)               <<   =   << (getid(r)) << endl;       };       l = getid(l), r = getid(r);       if (t == 1) {         int x;         cin >> x;         x ^= last;         uf.unite(l, r, x);       } else {         pair<int, int> p1 = uf.find(l), p2 = uf.find(r);         if (false) {           cerr <<  p1.first                 <<   =   << (p1.first) <<  ,                  <<  p2.first                 <<   =   << (p2.first) << endl;         };         if (p1.first != p2.first) {           last = 1;           fprintf(stdout,  %d , -1), putchar(  n );           ;         } else {           if (false) {             cerr <<  Q                   <<   =   << (Q) <<  ,                    <<  p1.second                   <<   =   << (p1.second) <<  ,                    <<  p2.second                   <<   =   << (p2.second) << endl;           };           last = p1.second ^ p2.second;           fprintf(stdout,  %d , last), putchar(  n );           ;         }       }     }     return 0;   }   