#include <bits/stdc++.h>
using namespace std;
map<int, int> par, val;
int find(int x) {
  if (par.find(x) == par.end()) {
    par[x] = x;
    val[x] = 0;
    return x;
  } else {
    if (x == par[x])
      return x;
    else {
      int p = find(par[x]);
      val[x] ^= val[par[x]];
      return par[x] = p;
    }
  }
}
inline void unite(int x, int y, int w) {
  int px = find(x), py = find(y);
  if (px == py) return;
  w ^= val[x] ^ val[y];
  par[px] = py;
  val[px] = w;
}
inline bool same(int x, int y) { return find(x) == find(y); }
int main() {
  int q, t, l, r, x, last = 0;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d%d", &t, &l, &r);
    l ^= last;
    r ^= last;
    if (l > r) swap(l, r);
    r++;
    if (t == 1) {
      scanf("%d", &x);
      x ^= last;
      unite(l, r, x);
    } else {
      if (!same(l, r)) {
        last = 1;
        puts("-1");
      } else {
        printf("%d\n", last = (val[l] ^ val[r]));
      }
    }
  }
  return 0;
}
