#include <bits/stdc++.h>
using namespace std;
int n, last;
map<int, int> fa, faxor;
int Find(int x) {
  if (x == fa[x]) return fa[x];
  int root = Find(fa[x]);
  faxor[x] ^= faxor[fa[x]];
  return fa[x] = root;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int op, a, b, c;
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d%d%d", &a, &b, &c);
      a ^= last;
      b ^= last;
      c ^= last;
      if (a > b) swap(a, b);
      b++;
      if (!fa.count(a)) fa[a] = a, faxor[a] = 0;
      if (!fa.count(b)) fa[b] = b, faxor[b] = 0;
      int l = Find(a), r = Find(b);
      if (l != r) {
        fa[l] = r;
        faxor[l] = faxor[a] ^ faxor[b] ^ c;
      }
    } else {
      scanf("%d%d", &a, &b);
      a ^= last;
      b ^= last;
      if (a > b) swap(a, b);
      b++;
      if (!fa.count(a) || !fa.count(b)) {
        last = 1;
        puts("-1");
        continue;
      } else {
        int l = Find(a), r = Find(b);
        if (l != r) {
          last = 1;
          puts("-1");
        } else {
          last = faxor[a] ^ faxor[b];
          printf("%d\n", last);
        }
      }
    }
  }
  return 0;
}
