#include <bits/stdc++.h>
const int N = 400005;
int n, f[N], w[N], idx;
std::map<int, int> M;
int getpos(int id) {
  return M.count(id) ? M[id] : (M[id] = ++idx, f[idx] = idx);
}
int find(int x) {
  if (x == f[x])
    return x;
  else {
    int p = find(f[x]);
    w[x] ^= w[f[x]];
    f[x] = p;
  }
}
int conn(int x, int y) { return find(x) == find(y); }
void link(int x, int y, int k) {
  int rx = find(x), ry = find(y);
  w[rx] = k ^ w[x] ^ w[y];
  f[rx] = ry;
}
int main() {
  std::scanf("%d", &n);
  int lst = 0;
  for (int i = 1; i <= n; i++) {
    int op, l, r;
    std::scanf("%d%d%d", &op, &l, &r);
    l ^= lst, r ^= lst;
    if (l > r) std::swap(l, r);
    if (op == 2) {
      if (!conn(getpos(l - 1), getpos(r)))
        std::puts("-1"), lst = 1;
      else
        std::printf("%d\n", lst = w[getpos(l - 1)] ^ w[getpos(r)]);
    } else {
      int x;
      std::scanf("%d", &x), x ^= lst;
      if (!conn(getpos(l - 1), getpos(r))) link(getpos(l - 1), getpos(r), x);
    }
  }
  return 0;
}
