#include <bits/stdc++.h>
using namespace std;
const int MAX = 4e5 + 10;
map<int, int> ma;
int p[MAX], r[MAX];
int f(int x) {
  if (p[x] == x) return x;
  int nex = p[x];
  p[x] = f(p[x]);
  r[x] ^= r[nex];
  return p[x];
}
int main() {
  for (int i = 1; i <= 4e5; i++) p[i] = i, r[i] = 0;
  int T, last = 0, cnt = 1;
  cin >> T;
  while (T--) {
    int op, x, y, z;
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d%d%d", &x, &y, &z);
      x ^= last;
      y ^= last;
      z ^= last;
      if (x > y) swap(x, y);
      x--;
      if (ma[x] == 0) ma[x] = cnt++;
      if (ma[y] == 0) ma[y] = cnt++;
      x = ma[x];
      y = ma[y];
      int fx = f(x), fy = f(y);
      if (fx == fy) continue;
      p[fy] = fx;
      r[fy] = r[y] ^ r[x] ^ z;
    } else {
      scanf("%d%d", &x, &y);
      x ^= last;
      y ^= last;
      if (x > y) swap(x, y);
      x--;
      if (ma[x] == 0) ma[x] = cnt++;
      if (ma[y] == 0) ma[y] = cnt++;
      x = ma[x];
      y = ma[y];
      int fx = f(x), fy = f(y);
      if (fx == fy)
        last = r[x] ^ r[y];
      else
        last = -1;
      printf("%d\n", last);
    }
    if (last == -1) last = 1;
  }
  return 0;
}
