#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
map<int, int> p, d;
int first(int x) {
  if (p[x] == x) return x;
  int pp = first(p[x]);
  d[x] ^= d[p[x]];
  p[x] = pp;
  return pp;
}
void kpc(int x, int y, int z) {
  int xx = first(x);
  int yy = first(y);
  if (rnd() % 2) swap(xx, yy);
  p[xx] = yy;
  d[xx] = d[x] ^ z ^ d[y];
}
void solv() {
  int qq;
  scanf("%d", &qq);
  int ans = 0;
  while (qq--) {
    int ty;
    scanf("%d", &ty);
    if (ty == 1) {
      int x, y, z;
      scanf("%d%d%d", &x, &y, &z);
      x ^= ans;
      y ^= ans;
      z ^= ans;
      if (x > y) swap(x, y);
      ++y;
      if (p.find(x) == p.end()) p[x] = x;
      if (p.find(y) == p.end()) p[y] = y;
      if (first(x) == first(y)) continue;
      kpc(x, y, z);
    } else {
      int x, y;
      scanf("%d%d", &x, &y);
      x ^= ans;
      y ^= ans;
      if (x > y) swap(x, y);
      ++y;
      if (p.find(x) == p.end()) p[x] = x;
      if (p.find(y) == p.end()) p[y] = y;
      if (first(x) != first(y))
        ans = -1;
      else {
        first(x);
        first(y);
        ans = (d[x] ^ d[y]);
      }
      printf("%d\n", ans);
      if (ans == -1) ans = 1;
    }
  }
}
int main() {
  solv();
  return 0;
}
