#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vpii = vector<pii>;
template <class T>
inline bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
inline bool ckmax(T& a, const T& b) {
  return b > a ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const char nl = '\n';
const int mxN = 4e5 + 10;
const int MOD = 1e9 + 7;
const ll infLL = 1e18;
const ld eps = 1e-6;
map<int, int> mp;
pii par[mxN];
int sz[mxN];
int q;
int cnt = 0;
pii Find(int v) {
  if (par[v].first == v) return par[v];
  auto r = Find(par[v].first);
  return {r.first, r.second ^ par[v].second};
}
void comb(int e3, int e4, int cost) {
  auto e1 = Find(e3), e2 = Find(e4);
  if (sz[e1.first] < sz[e2.first]) swap(e1.first, e2.first);
  sz[e1.first] += sz[e2.first];
  par[e2.first] = {e1.first, cost ^ e2.second ^ e1.second};
  sz[e2.first] = 0;
}
int32_t main() {
  cin.tie(0)->sync_with_stdio(0);
  for (int i = (0); i < (mxN); i++) par[i] = {i, 0}, sz[i] = 1;
  cin >> q;
  int lst = 0;
  for (int qn = (0); qn < (q); qn++) {
    int t;
    cin >> t;
    int l, r;
    cin >> l >> r;
    l ^= lst, r ^= lst;
    if (l > r) swap(l, r);
    r++;
    if (mp.count(l))
      l = mp[l];
    else {
      mp[l] = cnt++;
      l = mp[l];
    }
    if (mp.count(r))
      r = mp[r];
    else {
      mp[r] = cnt++;
      r = mp[r];
    }
    if (t == 1) {
      int x;
      cin >> x;
      x ^= lst;
      if (Find(l).first == Find(r).first) {
        continue;
      }
      comb(l, r, x);
    } else {
      if (Find(l).first == Find(r).first) {
        int res = Find(l).second;
        res ^= Find(r).second;
        cout << res << nl;
        lst = res;
      } else {
        cout << "-1\n";
        lst = 1;
      }
    }
  }
}
