#include <bits/stdc++.h>
using namespace std;
int fa[400010], val[400010], id[400010];
inline int getf(int x) {
  if (x == fa[x]) return x;
  int f = fa[x];
  fa[x] = getf(fa[x]);
  val[x] ^= val[f];
  return fa[x];
}
void merge(int x, int y, int w) {
  int ti = x, tj = y;
  x = getf(x);
  y = getf(y);
  w ^= val[ti] ^ val[tj];
  if (x == y) return;
  fa[x] = y;
  val[x] = w;
}
int nodecnt = 0;
inline int newnode(int x) {
  nodecnt++;
  id[nodecnt] = x;
  fa[nodecnt] = nodecnt;
  val[nodecnt] = 0;
  return nodecnt;
}
unordered_map<int, int> mp;
int lastans, q, opt, l, r, x;
int main() {
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d%d", &opt, &l, &r);
    l ^= lastans;
    r ^= lastans;
    if (l > r) swap(l, r);
    if (opt == 1) {
      scanf("%d", &x);
      x ^= lastans;
      if (mp.find(l - 1) == mp.end()) mp[l - 1] = newnode(l - 1);
      if (mp.find(r) == mp.end()) mp[r] = newnode(r);
      merge(mp[l - 1], mp[r], x);
    } else {
      if (mp.find(l - 1) == mp.end() || mp.find(r) == mp.end()) {
        puts("-1");
        lastans = 1;
        continue;
      }
      l = mp[l - 1];
      r = mp[r];
      if (getf(l) != getf(r)) {
        puts("-1");
        lastans = 1;
      } else
        printf("%d\n", lastans = (val[l] ^ val[r]));
    }
  }
  return 0;
}
