#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
const int iinf = 1 << 29;
const long long inf = 1ll << 60;
const long long mod = 1e9 + 7;
void GG() {
  cout << "No\n";
  exit(0);
}
long long mpow(long long a, long long n) {
  long long re = 1;
  while (n > 0) {
    if (n & 1) re = re * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return re;
}
long long inv(long long b) {
  if (b == 1) return b;
  return (mod - mod / b) * inv(mod % b) % mod;
}
const int maxn = 1e5 + 5;
struct DSU {
  vector<int> pxor, par, rnk;
  vector<vector<pair<int, int> > > g;
  int mx;
  DSU(int sz) {
    mx = sz;
    pxor.resize(sz);
    par.resize(sz);
    rnk.resize(sz, 1);
    g.resize(sz);
    for (int i = 0; i < (sz); i++) par[i] = i;
  }
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }
  void dfs(int v, int p) {
    for (pair<int, int> xx : g[v]) {
      if (xx.first != p) {
        pxor[xx.first] = pxor[v] ^ xx.second;
        dfs(xx.first, v);
      }
    }
  }
  void merge(int a, int b, int w) {
    int A = find(a), B = find(b);
    if (A == B) return;
    g[a].push_back({b, w});
    g[b].push_back({a, w});
    if (rnk[A] < rnk[B]) {
      swap(a, b);
      swap(A, B);
    }
    pxor[b] = w ^ pxor[a];
    dfs(b, a);
    rnk[A] += rnk[B];
    par[B] = A;
  }
  int que(int a, int b) {
    int A = find(a), B = find(b);
    if (A != B) return -1;
    return pxor[a] ^ pxor[b];
  }
};
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int q;
  cin >> q;
  map<int, int> mp;
  DSU dd(4e5 + 100);
  int id = 1;
  int last = 0;
  for (int i = 0; i < (q); i++) {
    int tp;
    cin >> tp;
    int l, r;
    cin >> l >> r;
    l ^= last;
    r ^= last;
    if (l > r) swap(l, r);
    r++;
    int L = mp[l], R = mp[r];
    if (L == 0) L = mp[l] = id++;
    if (R == 0) R = mp[r] = id++;
    if (tp == 2) {
      int ans = dd.que(L, R);
      cout << ans << '\n';
      last = abs(ans);
    } else {
      int x;
      cin >> x;
      x ^= last;
      dd.merge(L, R, x);
    }
  }
}
