#include <bits/stdc++.h>
using namespace std;
map<int, int> fa, R;
int q, op, l, r, lt, x;
int fin(int u) {
  if (fa.find(u) == fa.end()) return u;
  int v = fin(fa[u]);
  R[u] ^= R[fa[u]];
  return fa[u] = v;
}
void un(int u, int v, int tp) {
  int x = fin(u), y = fin(v);
  if (x == y) return;
  fa[x] = y;
  R[x] = R[u] ^ R[v] ^ tp;
}
int main() {
  cin >> q;
  while (q--) {
    scanf("%d%d%d", &op, &l, &r);
    l ^= lt;
    r ^= lt;
    if (l > r) swap(l, r);
    r++;
    if (op == 1) {
      scanf("%d", &x);
      x ^= lt;
      un(l, r, x);
    } else {
      if (fin(l) == fin(r))
        lt = R[l] ^ R[r];
      else
        lt = -1;
      printf("%d\n", lt);
      if (lt == -1) lt = 1;
    }
  }
}
