#include <bits/stdc++.h>
using namespace std;
map<int, int> father, num;
int n, l, r, x, lst = 0, q, opt;
int find_(int x) {
  if (!father.count(x)) return x;
  int tmp = find_(father[x]);
  num[x] ^= num[father[x]];
  father[x] = tmp;
  return father[x];
}
inline int read() {
  register int x = 0, w = 1;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  if (ch == '-') w = -1;
  while (isdigit(ch)) x = ((x << 3) + (x << 1)) + ch - '0', ch = getchar();
  return x * w;
}
int main() {
  q = read();
  while (q--) {
    opt = read();
    if (opt == 1) {
      l = read();
      r = read();
      x = read();
      l ^= lst, r ^= lst, x ^= lst;
      if (l > r) swap(l, r);
      --l;
      int xf = find_(l), yf = find_(r);
      if (xf != yf) {
        father[yf] = xf;
        num[yf] = x ^ num[l] ^ num[r];
      }
    } else {
      l = read();
      r = read();
      l ^= lst;
      r ^= lst;
      if (l > r) swap(l, r);
      --l;
      int xf = find_(l), yf = find_(r);
      if (xf != yf) {
        lst = 1;
        puts("-1");
      } else {
        lst = num[l] ^ num[r];
        printf("%d\n", lst);
      }
    }
  }
  return 0;
}
