#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 7;
const int infint = (int)1e9;
const long long inf = (long long)1e18;
unordered_map<long long, long long> par, sm;
long long last = 0;
pair<long long, long long> getpar2(long long v) {
  if (par.count(v) == 0) {
    return {0, v};
  } else {
    pair<long long, long long> tmp = getpar2(par[v]);
    par[v] = tmp.second;
    sm[v] = sm[v] ^ tmp.first;
    return {sm[v], par[v]};
  }
}
void print(long long p) {
  if (p == -1)
    last = 1;
  else
    last = p;
  cout << p << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    long long type;
    cin >> type;
    if (type == 1) {
      long long a, b, c;
      cin >> a >> b >> c;
      a = a ^ last, b = b ^ last, c = c ^ last;
      if (a > b) swap(a, b);
      b++;
      if (getpar2(a).second == getpar2(b).second) {
        if (((getpar2(a).first) ^ (getpar2(b).first)) != c) continue;
      } else {
        pair<long long, long long> v = getpar2(a);
        pair<long long, long long> u = getpar2(b);
        c = c ^ (v.first);
        c = c ^ (u.first);
        par[v.second] = u.second;
        sm[v.second] = c;
      }
    } else {
      long long a, b;
      cin >> a >> b;
      a = a ^ last, b = b ^ last;
      if (a > b) swap(a, b);
      b++;
      long long T1 = getpar2(a).second, T2 = getpar2(b).second;
      if (T1 == T2) {
        pair<long long, long long> v = getpar2(a);
        pair<long long, long long> u = getpar2(b);
        long long c = 0;
        c = c ^ (v.first);
        c = c ^ (u.first);
        print(c);
      } else
        print(-1);
    }
  }
}
