#include <bits/stdc++.h>
using namespace std;
int n, m, q, last, peso[400050], pai[400050], superpai[400050], cnt,
    pxor[400050];
unordered_map<int, int> compress;
vector<int> filhos[400050];
vector<pair<int, int> > hist[400050], grafo[400050];
inline void dfs(int x, int p) {
  for (auto v : grafo[x]) {
    if (v.first == p) continue;
    pxor[v.first] = (pxor[x] ^ v.second);
    dfs(v.first, x);
  }
}
inline int Find(int x) {
  if (x == pai[x]) return x;
  return pai[x] = Find(pai[x]);
}
inline void join(int a, int b, int c) {
  int sa = Find(a), sb = Find(b);
  if (sa == sb) return;
  if (peso[sa] >= peso[sb]) {
    grafo[b].push_back({a, c});
    grafo[a].push_back({b, c});
    pxor[b] = (pxor[a] ^ c);
    dfs(b, a);
    pai[sb] = sa;
    peso[sa] += peso[sb];
  } else {
    swap(a, b);
    grafo[b].push_back({a, c});
    grafo[a].push_back({b, c});
    pxor[b] = (pxor[a] ^ c);
    pai[sb] = sa;
    peso[sa] += peso[sb];
    dfs(b, a);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> q;
  for (int i = 1, t, l, r, x; i <= q; i++) {
    cin >> t >> l >> r;
    l ^= last, r ^= last;
    if (l > r) swap(l, r);
    if (!compress[l - 1]) {
      compress[l - 1] = ++cnt;
      pai[cnt] = cnt;
      peso[cnt] = 1;
    }
    if (!compress[r]) {
      compress[r] = ++cnt;
      pai[cnt] = cnt;
      peso[cnt] = 1;
    }
    int a = l, b = r;
    l = compress[l - 1], r = compress[r];
    if (t == 1) {
      cin >> x;
      x ^= last;
      join(l, r, x);
    } else {
      if (Find(l) == Find(r))
        last = (pxor[l] ^ pxor[r]);
      else
        last = -1;
      cout << last << "\n";
      if (last < 0) last = 1;
    }
  }
}
