#include <bits/stdc++.h>
using namespace std;
map<int, int> par, r;
map<int, int>::iterator it;
int find(int u) {
  it = par.find(u);
  if (it == par.end()) {
    r[u] = 0;
    return u;
  }
  int v = par[u];
  int tmp = find(v);
  r[u] ^= r[v];
  return par[u] = tmp;
}
void join(int a, int b, int x) {
  int c = find(a), d = find(b);
  if (c == d) return;
  par[c] = d;
  r[c] = r[a] ^ r[b] ^ x;
}
int main() {
  int q, a, b, last = 0, op, x;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d%d", &op, &a, &b);
    a ^= last, b ^= last;
    if (a > b) swap(a, b);
    b++;
    if (op == 1) {
      scanf("%d", &x);
      join(a, b, x ^ last);
    } else {
      if (find(a) != find(b))
        last = -1;
      else
        last = r[a] ^ r[b];
      printf("%d\n", last);
      last = abs(last);
    }
  }
}
