#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 9;
int q, lastans;
map<int, int> fa, b;
int find(int x) {
  if (!fa.count(x)) return x;
  int tmp = find(fa[x]);
  b[x] ^= b[fa[x]];
  fa[x] = tmp;
  return fa[x];
}
int main() {
  scanf("%d", &q);
  while (q--) {
    int op, l, r, x;
    scanf("%d%d%d", &op, &l, &r);
    l ^= lastans, r ^= lastans;
    if (l > r) swap(l, r);
    ++r;
    int fl = find(l), fr = find(r);
    if (op == 1) {
      scanf("%d", &x);
      x ^= lastans;
      if (fl == fr) continue;
      fa[fr] = fl;
      b[fr] = b[l] ^ b[r] ^ x;
    } else {
      if (fl != fr) {
        puts("-1");
        lastans = 1;
        continue;
      }
      printf("%d\n", lastans = b[l] ^ b[r]);
    }
  }
  return 0;
}
