#include <bits/stdc++.h>
using namespace std;
map<int, int> fa, num;
int _find(int x) {
  if (!fa.count(x)) return x;
  int i = fa[x];
  fa[x] = _find(fa[x]);
  num[x] ^= num[i];
  return fa[x];
}
int main() {
  int ls = 0;
  int q;
  scanf("%d", &q);
  while (q--) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      int l, r, x;
      scanf("%d %d %d", &l, &r, &x);
      l ^= ls, r ^= ls, x ^= ls;
      if (l > r) swap(l, r);
      l--;
      int fl = _find(l), fr = _find(r);
      if (fl != fr) {
        fa[fl] = fr;
        num[fl] = num[r] ^ x ^ num[l];
      }
    } else {
      int l, r;
      scanf("%d %d", &l, &r);
      l ^= ls, r ^= ls;
      if (l > r) swap(l, r);
      l--;
      int fl = _find(l), fr = _find(r);
      if (fl != fr) {
        puts("-1");
        ls = 1;
      } else {
        int ans = num[l] ^ num[r];
        ls = ans;
        printf("%d\n", ans);
      }
    }
  }
  return 0;
}
