#include <bits/stdc++.h>
using namespace std;
map<int, int> f, s;
int q;
int find(int x) {
  if (f.find(x) == f.end()) return x;
  int fx = find(f[x]);
  s[x] ^= s[f[x]];
  return f[x] = fx;
}
void _merge(int x, int y, int k) {
  int fx = find(x), fy = find(y);
  if (fx == fy) return;
  f[fx] = fy;
  s[fx] = s[x] ^ s[y] ^ k;
}
int main() {
  scanf("%d", &q);
  int lst = 0;
  while (q--) {
    int opt, l, r;
    scanf("%d%d%d", &opt, &l, &r);
    l ^= lst, r ^= lst;
    if (l > r) swap(l, r);
    r++;
    if (opt == 1) {
      int x;
      scanf("%d", &x);
      x ^= lst;
      _merge(l, r, x);
    } else {
      int res;
      if (find(l) != find(r))
        res = -1;
      else
        res = s[l] ^ s[r];
      printf("%d\n", res);
      lst = abs(res);
    }
  }
  return 0;
}
