#include <bits/stdc++.h>
using namespace std;
int q, t, l, r, x, last;
map<int, int> fa, Xor;
int find(int x) {
  if (fa[x] == x) return x;
  int root = find(fa[x]);
  Xor[x] ^= Xor[fa[x]];
  return fa[x] = root;
}
int main() {
  while (scanf("%d", &q) != EOF) {
    fa.clear();
    Xor.clear();
    last = 0;
    while (q--) {
      scanf("%d%d%d", &t, &l, &r);
      if (t == 1) {
        scanf("%d", &x);
        l ^= last;
        r ^= last;
        x ^= last;
        if (l > r) swap(l, r);
        ++r;
        if (fa.find(l) == fa.end()) fa[l] = l, Xor[l] = 0;
        if (fa.find(r) == fa.end()) fa[r] = r, Xor[r] = 0;
        int fl = find(l), fr = find(r);
        if (fl != fr) {
          fa[fl] = fr;
          Xor[fl] = Xor[l] ^ Xor[r] ^ x;
        }
      } else {
        l ^= last;
        r ^= last;
        if (l > r) swap(l, r);
        ++r;
        if (fa.find(l) == fa.end() || fa.find(r) == fa.end()) {
          last = 1;
          puts("-1");
          continue;
        }
        int fl = find(l), fr = find(r);
        if (fl != fr) {
          last = 1;
          puts("-1");
        } else {
          last = Xor[l] ^ Xor[r];
          printf("%d\n", last);
        }
      }
    }
  }
  return 0;
}
