#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read(T& x) {
  x = 0;
  int f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') f |= (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x = f ? -x : x;
}
int q, t, l, r, x, last;
map<int, int> fa;
map<int, int> val;
int Find(int x) {
  if (fa.find(x) == fa.end()) return fa[x] = x;
  if (fa[x] == x) return x;
  int root = Find(fa[x]);
  val[x] ^= val[fa[x]];
  return fa[x] = root;
}
int main() {
  for (read(q); q--;) {
    read(t);
    if (t == 1) {
      read(l), read(r), read(x);
      l ^= last, r ^= last, x ^= last;
      if (l > r) swap(l, r);
      l--;
      int p = Find(l), q = Find(r);
      if (p ^ q) {
        if (p < q) swap(p, q);
        fa[p] = q;
        val[p] = val[l] ^ val[r] ^ x;
      }
    } else {
      read(l), read(r);
      l ^= last, r ^= last;
      if (l > r) swap(l, r);
      l--;
      int p = Find(l), q = Find(r);
      if (p == q) {
        printf("%d\n", val[p] ^ val[l] ^ val[r]);
        last = val[p] ^ val[l] ^ val[r];
      } else {
        puts("-1");
        last = 1;
      }
    }
  }
  return 0;
}
