#include <bits/stdc++.h>
using namespace std;
int par[400000];
int val[400000];
int get(int x) {
  if (x == par[x]) return x;
  int root = get(par[x]);
  val[x] ^= val[par[x]];
  return par[x] = root;
}
void join(int l, int r, int x) {
  int pl = get(l), pr = get(r);
  x ^= val[l] ^ val[r];
  if (pl == pr) return;
  if (rand() & 1) swap(pl, pr);
  par[pr] = pl;
  val[pr] = x;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  unordered_map<int, int> mp;
  iota(begin(par), end(par), 0);
  int q, last = 0;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int t, l, r;
    cin >> t >> l >> r;
    l ^= last, r ^= last;
    if (l > r) swap(l, r);
    r++;
    mp.emplace(l, mp.size());
    l = mp[l];
    mp.emplace(r, mp.size());
    r = mp[r];
    if (t == 1) {
      int x;
      cin >> x;
      join(l, r, x ^ last);
    } else {
      last = get(l) == get(r) ? val[l] ^ val[r] : -1;
      cout << last << '\n';
      if (last == -1) last = 1;
    }
  }
}
