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