#include <bits/stdc++.h>
using namespace std;
template <typename T>
T read1() {
  T t = 0;
  bool vis = 0;
  char k;
  do (k = getchar()) == '-' && (vis = 1);
  while ('0' > k || k > '9');
  while ('0' <= k && k <= '9')
    t = (t << 3) + (t << 1) + (k ^ '0'), k = getchar();
  return vis ? -t : t;
}
int s;
struct node {
  node *fa;
  int v;
  node() {
    fa = this;
    v = 0;
  }
};
map<int, node *> ma;
node *find(node *n) {
  if (n->fa == n) return n;
  node *tem = n->fa;
  n->fa = find(n->fa);
  n->v ^= tem->v;
  return n->fa;
  ;
}
void Merge(node *x, node *y, int t) {
  node *tx = find(x), *ty = find(y);
  if (tx != ty) {
    ty->fa = tx;
    ty->v = x->v ^ y->v ^ t;
  }
}
bool judge(node *x, node *y) { return find(x) == find(y); }
int main() {
  s = read1<long long>();
  int la = 0;
  for (int i = 1; i <= s; ++i) {
    int opt = read1<long long>(), l = read1<long long>() ^ la,
        r = read1<long long>() ^ la;
    if (l > r) swap(l, r);
    ++r;
    if (!ma[l]) ma[l] = new node();
    if (!ma[r]) ma[r] = new node();
    if (opt & 1) {
      int x = read1<long long>();
      if (judge(ma[l], ma[r])) continue;
      Merge(ma[l], ma[r], x ^ la);
    } else {
      if (!judge(ma[l], ma[r])) {
        la = 1;
        puts("-1");
        continue;
      }
      printf("%d\n", la = ma[l]->v ^ ma[r]->v);
    }
  }
  return 0;
}
