#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e4 + 5, inf = 1e18, mod = 998244353;
long long q, k = 1, lst;
map<long long, long long> par, xpr, sz;
pair<long long, long long> get_par(long long u) {
  if (par[u] == 0) return {u, 0};
  pair<long long, long long> p = get_par(par[u] - 1);
  p.second ^= xpr[u];
  xpr[u] = p.second;
  par[u] = p.first + 1ll;
  return p;
}
void update(long long l, long long r, long long x) {
  r++;
  if (sz[l] == 0) sz[l] = 1;
  if (sz[r] == 0) sz[r] = 1;
  pair<long long, long long> p1 = get_par(l);
  pair<long long, long long> p2 = get_par(r);
  if (p1.first == p2.first) return;
  if (sz[p1.first] < sz[p2.first]) swap(p1, p2);
  sz[p1.first] += sz[p2.first];
  par[p2.first] = p1.first + 1ll;
  xpr[p2.first] = x ^ p1.second ^ p2.second;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> q;
  while (q--) {
    long long t;
    cin >> t;
    if (t == 1) {
      long long l, r, x;
      cin >> l >> r >> x;
      l ^= lst;
      r ^= lst;
      if (r < l) swap(l, r);
      x ^= lst;
      update(l, r, x);
      continue;
    }
    long long l, r;
    cin >> l >> r;
    l ^= lst;
    r ^= lst;
    if (r < l) swap(l, r);
    r++;
    if (sz[l] == 0) sz[l] = 1;
    if (sz[r] == 0) sz[r] = 1;
    pair<long long, long long> p1 = get_par(l);
    pair<long long, long long> p2 = get_par(r);
    if (p1.first != p2.first) {
      cout << -1 << "\n";
      lst = 1;
      continue;
    }
    lst = (p1.second ^ p2.second);
    cout << lst << "\n";
  }
}
