#include <bits/stdc++.h>
using namespace std;
map<int, int> pre, ans;
map<int, int>::iterator it;
int f(int x) {
  it = pre.find(x);
  if (it == pre.end()) {
    ans[x] = 0;
    return x;
  } else {
    int b = it->second;
    int c = f(b);
    ans[x] ^= ans[b];
    return pre[x] = c;
  }
}
int update(int l, int r, int x) {
  int L = f(l), R = f(r);
  if (L == R) {
    return -1;
  } else {
    pre[R] = L;
    ans[R] = ans[l] ^ ans[r] ^ x;
    return 1;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  int last = 0;
  while (q--) {
    int t, l, r;
    cin >> t >> l >> r;
    l = l ^ last, r = r ^ last;
    if (l > r) swap(l, r);
    r++;
    if (t == 1) {
      int x;
      cin >> x;
      update(r, l, x ^ last);
    } else {
      if (f(l) != f(r))
        last = -1;
      else
        last = ans[r] ^ ans[l];
      cout << last << endl;
      last = abs(last);
    }
  }
  return 0;
}
