#include <bits/stdc++.h>
using namespace std;
map<int, int> fa, ans;
int q, lst;
int findSet(int x) {
  if (!fa.count(x)) return x;
  int t = findSet(fa[x]);
  ans[x] ^= ans[fa[x]];
  fa[x] = t;
  return fa[x];
}
int main() {
  scanf("%d", &q);
  while (q--) {
    int flag, l, r, x;
    scanf("%d", &flag);
    if (flag == 1) {
      scanf("%d %d %d", &l, &r, &x);
      l ^= lst, r ^= lst, x ^= lst;
      if (l > r) swap(l, r);
      l--;
      int u = findSet(l), v = findSet(r);
      if (u != v) {
        fa[u] = v;
        ans[u] = x ^ ans[l] ^ ans[r];
      }
    } else {
      scanf("%d %d", &l, &r);
      l ^= lst, r ^= lst;
      if (l > r) swap(l, r);
      l--;
      int u = findSet(l), v = findSet(r);
      if (u == v) {
        lst = ans[l] ^ ans[r];
        printf("%d\n", lst);
      } else {
        lst = 1;
        printf("-1\n");
      }
    }
  }
  return 0;
}
