#include <bits/stdc++.h>
using namespace std;
const long long mo = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
template <typename _T>
_T Fabs(_T x) {
  return x < 0 ? -x : x;
}
int q, las;
map<int, int> fa, num;
int findSet(int x) {
  if (!fa.count(x)) return x;
  int tmp = findSet(fa[x]);
  num[x] ^= num[fa[x]];
  fa[x] = tmp;
  return fa[x];
}
signed main() {
  scanf("%d", &q);
  while (q--) {
    int opt, l, r;
    scanf("%d %d %d", &opt, &l, &r);
    l ^= las;
    r ^= las;
    if (opt == 1) {
      int x;
      scanf("%d", &x);
      x ^= las;
      if (l > r) swap(l, r);
      l--;
      int u = findSet(l), v = findSet(r);
      if (u != v) fa[u] = v, num[u] = x ^ num[l] ^ num[r];
    } else {
      if (l > r) swap(l, r);
      l--;
      int u = findSet(l), v = findSet(r);
      if (u != v)
        las = 1, puts("-1");
      else
        las = num[l] ^ num[r], printf("%d\n", las);
    }
  }
  return 0;
}
