#include <bits/stdc++.h>
using namespace std;
const long long N = 4e5;
const long long mod = 100003;
inline long long read() {
  long long s = 0;
  register bool neg = 0;
  register char c = getchar();
  for (; c < '0' || c > '9'; c = getchar()) neg |= (c == '-');
  for (; c >= '0' && c <= '9'; s = s * 10 + (c ^ 48), c = getchar())
    ;
  s = (neg ? -s : s);
  return s;
}
long long a, top, fa[N + 10], val[N + 10], s[N + 10];
unordered_map<long long, long long> mp;
inline long long f(long long n) {
  if (n == fa[n]) return n;
  long long tmp = fa[n], F = f(fa[n]);
  val[n] ^= val[tmp];
  return fa[n] = F;
}
signed main() {
  a = read();
  long long lst = 0, x, l, r, opt;
  while (a--) {
    opt = read();
    l = read() ^ lst;
    r = read() ^ lst;
    if (l > r) swap(l, r);
    --l;
    if (opt == 1) {
      x = read() ^ lst;
      if (!mp.count(l)) {
        mp[l] = ++top;
        fa[top] = top;
        s[top] = l;
      }
      if (!mp.count(r)) {
        mp[r] = ++top;
        fa[top] = top;
        s[top] = r;
      }
      l = mp[l];
      r = mp[r];
      long long f1 = f(l), f2 = f(r);
      if (f1 == f2) continue;
      long long v1 = val[l], v2 = val[r] ^ x;
      if (s[f1] > s[f2]) swap(f1, f2), swap(v1, v2);
      fa[f1] = f2;
      val[f1] = v1 ^ v2;
    } else {
      if (!mp.count(l) || !mp.count(r)) {
        lst = 1;
        puts("-1");
        continue;
      }
      l = mp[l];
      r = mp[r];
      long long f1 = f(l), f2 = f(r);
      if (f1 != f2) {
        lst = 1;
        puts("-1");
        continue;
      }
      printf("%lld\n", lst = (val[l] ^ val[r]));
    }
  }
  return 0;
}
