#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9') {
    if (c == '-') f = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
int q, ans;
map<int, int> fa, s;
int find(int x) {
  if (!fa.count(x)) return x;
  int tmp = find(fa[x]);
  s[x] ^= s[fa[x]];
  fa[x] = tmp;
  return fa[x];
}
void merge(int u, int v, int c) {
  int x = find(u), y = find(v);
  if (x == y) return;
  fa[x] = y;
  s[x] = s[u] ^ c ^ s[v];
}
signed main() {
  q = read();
  while (q--) {
    int op = read(), l = read() ^ ans, r = read() ^ ans;
    if (l > r) swap(l, r);
    r++;
    if (op == 1) {
      int x = read() ^ ans;
      merge(l, r, x);
    } else {
      if (find(l) != find(r)) {
        ans = 1;
        puts("-1");
      } else {
        ans = s[l] ^ s[r];
        printf("%d\n", ans);
      }
    }
  }
}
