#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int par[500005], up[500005], sz[500005], CLK;
pair<int, int> get(int x) {
  int val = 0;
  while (par[x] != x) {
    val ^= up[x];
    x = par[x];
  }
  return {x, val};
}
void unite(int x, int y, int val) {
  auto r1 = get(x), r2 = get(y);
  val ^= r1.second ^ r2.second;
  int X = r1.first, Y = r2.first;
  if (X == Y) return;
  if (sz[X] < sz[Y]) swap(X, Y);
  par[Y] = X, up[Y] = val, sz[X] += sz[Y];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q, last = 0, l, r, x, type;
  iota(par, par + 500005, 0);
  fill(sz, sz + 500005, 1);
  for (cin >> q; q--;) {
    cin >> type >> l >> r;
    l ^= last, r ^= last;
    if (l > r) swap(l, r);
    ++r;
    if (mp.find(l) == mp.end()) mp[l] = ++CLK;
    if (mp.find(r) == mp.end()) mp[r] = ++CLK;
    l = mp[l], r = mp[r];
    if (type == 1) {
      cin >> x;
      unite(l, r, x ^ last);
    } else {
      auto r1 = get(l), r2 = get(r);
      if (r1.first == r2.first)
        cout << (last = r1.second ^ r2.second) << '\n';
      else
        cout << -(last = 1) << '\n';
    }
  }
}
