#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 5e5 + 5;
int q, t, l, r, x, cnt, last, par[N], d[N];
vector<int> comp[N];
vector<pair<int, int> > g[N];
map<int, int> mp;
void dfs(int s, int p, int w) {
  d[s] = w;
  for (auto e : g[s]) {
    if (e.first != p) dfs(e.first, s, w ^ e.second);
  }
}
void Unite(int u, int v, int w) {
  int pu = par[u];
  int pv = par[v];
  g[u].push_back({v, w});
  g[v].push_back({u, w});
  if ((int)comp[pu].size() < (int)comp[pv].size()) {
    dfs(u, v, w ^ d[v]);
    for (auto e : comp[pu]) {
      comp[pv].push_back(e);
      par[e] = pv;
    }
  } else {
    dfs(v, u, w ^ d[u]);
    for (auto e : comp[pv]) {
      comp[pu].push_back(e);
      par[e] = pu;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> q;
  while (q--) {
    cin >> t >> l >> r;
    l ^= last;
    r ^= last;
    if (l > r) swap(l, r);
    r++;
    if (!mp[l]) {
      mp[l] = ++cnt;
      d[cnt] = 0;
      par[cnt] = cnt;
      comp[cnt].push_back(cnt);
    }
    if (!mp[r]) {
      mp[r] = ++cnt;
      d[cnt] = 0;
      par[cnt] = cnt;
      comp[cnt].push_back(cnt);
    }
    l = mp[l];
    r = mp[r];
    if (t == 1) {
      int w;
      cin >> w;
      w ^= last;
      if (par[l] == par[r]) continue;
      Unite(l, r, w);
    } else {
      if (par[l] != par[r]) {
        cout << "-1"
             << "\n";
        last = 1;
        continue;
      }
      last = d[l] ^ d[r];
      cout << last << "\n";
    }
  }
  return 0;
}
