#include <bits/stdc++.h>
using namespace std;
int q;
map<int, int> val;
map<int, int> par;
map<int, bool> vis;
map<int, vector<int>> child;
bool exists(int a) { return par.find(a) != par.end(); }
int solve(int a, int b) {
  if (!exists(a) || !exists(b)) return -1;
  if (par[a] != par[b]) return -1;
  return val[a] ^ val[b];
}
void ins(int x) {
  if (exists(x)) return;
  par[x] = x, val[x] = 0;
  child[x] = {x};
}
void upd(int a, int b, int x) {
  if (solve(a, b) != -1) return;
  ins(a), ins(b);
  int A = par[a], B = par[b];
  if (child[A].size() < child[B].size()) {
    swap(a, b);
    swap(A, B);
  }
  x ^= val[a] ^ val[b];
  for (int i : child[B]) {
    child[A].push_back(i);
    val[i] ^= x;
    par[i] = A;
  }
  child.erase(B);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> q;
  int last = 0;
  while (q--) {
    int t, l, r, x;
    cin >> t;
    if (t == 1) {
      cin >> l >> r >> x;
      l ^= last;
      r ^= last;
      x ^= last;
      if (l > r) swap(l, r);
      upd(l, r + 1, x);
    } else {
      cin >> l >> r;
      l ^= last;
      r ^= last;
      if (l > r) swap(l, r);
      last = solve(l, r + 1);
      cout << last << '\n';
      if (last == -1) last = 1;
    }
  }
  return 0;
}
