#include <bits/stdc++.h>
using namespace std;
namespace IO {
void read(int &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  while ('0' > c || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  x *= f;
}
void write(int x) {
  if (x < 0) {
    putchar('-');
    write(-x);
    return;
  }
  if (x < 10)
    putchar(x + '0');
  else {
    write(x / 10);
    putchar(x % 10 + '0');
  }
}
}  // namespace IO
using namespace IO;
struct node {
  int fa[400005];
  int w[400005];
  void makeset(int n) {
    for (int i = 1; i <= n; i++) fa[i] = i;
  }
  int findset(int x) {
    if (fa[x] == x) return x;
    int t = findset(fa[x]);
    w[x] ^= w[fa[x]];
    return fa[x] = t;
  }
  void merge(int u, int v, int ty) {
    swap(u, v);
    int a = findset(u);
    int b = findset(v);
    fa[a] = b;
    w[a] = w[u] ^ ty ^ w[v];
    w[b] = 0;
  }
} t;
int ty;
int n, cnt;
int lans;
map<int, int> hashh;
int opt, l, r, x;
void divide(int val, int *a) {
  for (int i = 0; i <= 30; i++) a[i] = 0;
  int len = 0;
  while (val) {
    a[len++] = (val & 1);
    val >>= 1;
  }
  len--;
}
int main() {
  read(n);
  t.makeset(2 * n);
  for (int i = 1; i <= n; i++) {
    read(opt);
    read(l);
    read(r);
    l ^= lans;
    r ^= lans;
    if (l > r) swap(l, r);
    l--;
    if (hashh.count(l) == 0) hashh[l] = ++cnt;
    if (hashh.count(r) == 0) hashh[r] = ++cnt;
    l = hashh[l];
    r = hashh[r];
    if (opt == 1) {
      read(x);
      x ^= lans;
      if (t.findset(l) != t.findset(r)) t.merge(l, r, x);
    } else {
      lans = 0;
      if (t.findset(l) != t.findset(r)) {
        lans = 1;
        write(-lans);
        putchar('\n');
      } else {
        lans = (t.w[l] ^ t.w[r]);
        write(lans);
        putchar('\n');
      }
    }
  }
  return 0;
}
