#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double eps = 1e-12;
const int N = 3e5 + 5;
const int mod = 998244353;
map<int, int> par, r;
int Find(int u) {
  if (!par[u]) return u;
  int tmp = Find(par[u]);
  r[u] ^= r[par[u]];
  return par[u] = tmp;
}
void join(int a, int b, int k) {
  int fa = Find(a), fb = Find(b);
  if (fa == fb) return;
  par[fa] = fb;
  r[fa] = r[a] ^ r[b] ^ k;
}
int main() {
  int q, a, b, k, last = 0, op;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d%d", &op, &a, &b);
    a ^= last;
    b ^= last;
    if (a > b) swap(a, b);
    b++;
    if (op == 1) {
      scanf("%d", &k);
      join(a, b, k ^ last);
    } else {
      if (Find(a) != Find(b))
        last = -1;
      else
        last = r[a] ^ r[b];
      printf("%d\n", last);
      if (last < 0) last = -last;
    }
  }
  return 0;
}
