#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
map<int, int> f, val;
int lastans;
int read() {
  int x = 0, f = 1;
  char s;
  while ((s = getchar()) > '9' || s < '0')
    if (s == '-') f = -1;
  while (s >= '0' && s <= '9')
    x = (x << 1) + (x << 3) + (s ^ 48), s = getchar();
  return x * f;
}
int Find(int x) {
  if (!f.count(x)) return x;
  int t = Find(f[x]);
  val[x] ^= val[f[x]];
  return f[x] = t;
}
int main() {
  int op, u, v, w, x, y;
  for (int t = read(); t; --t) {
    op = read(), u = read() ^ lastans, v = read() ^ lastans;
    if (u > v) swap(u, v);
    --u;
    x = Find(u), y = Find(v);
    if (op == 1) {
      w = read() ^ lastans;
      if (x ^ y) {
        f[x] = y;
        val[x] = val[u] ^ val[v] ^ w;
      }
    } else {
      if (x ^ y)
        puts("-1"), lastans = 1;
      else
        printf("%d\n", val[u] ^ val[v]), lastans = val[u] ^ val[v];
    }
  }
  return 0;
}
