#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long a, long long b, long long m) {
  if (b == 0LL) return 1LL;
  if (b == 1LL) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1LL) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
struct DSU {
  vector<long long> p, dist;
  DSU() {}
  DSU(long long n) {
    p = dist = vector<long long>(n + 1, 0);
    for (long long i = 1; i <= n; i++) {
      p[i] = i;
      dist[i] = 0;
    }
  }
  pair<long long, long long> get(long long x) {
    if (p[x] == x) {
      return pair<long long, long long>(x, dist[x]);
    }
    pair<long long, long long> o = get(p[x]);
    dist[x] ^= dist[p[x]];
    p[x] = o.first;
    return pair<long long, long long>(o.first, dist[x]);
  }
  bool join(long long a, long long b, long long x) {
    pair<long long, long long> bef = get(a), bef2 = get(b);
    a = get(a).first, b = get(b).first;
    if (a == b) return 0;
    p[a] = b;
    dist[a] ^= (x ^ bef.second ^ bef2.second);
    return 1;
  }
};
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long q;
  cin >> q;
  DSU dsu(2 * q);
  long long L, R, X, l, r, x;
  long long last = 0;
  long long cnt = 0;
  map<long long, long long> mp;
  while (q--) {
    long long op;
    cin >> op;
    if (op == 1) {
      cin >> L >> R >> X;
      l = L ^ last, r = R ^ last, x = X ^ last;
      if (l > r) swap(l, r);
      r++;
      if (!mp.count(l)) mp[l] = ++cnt;
      if (!mp.count(r)) mp[r] = ++cnt;
      dsu.join(mp[l], mp[r], x);
    } else {
      cin >> L >> R;
      l = L ^ last, r = R ^ last;
      if (l > r) swap(l, r);
      r++;
      if (!mp.count(l) || !mp.count(r)) {
        last = 1;
        cout << -1 << "\n";
        continue;
      }
      long long ans = 0;
      l = mp[l], r = mp[r];
      if (dsu.get(l).first != dsu.get(r).first)
        ans = -1;
      else {
        pair<long long, long long> a = dsu.get(l), b = dsu.get(r);
        ans = a.second ^ b.second;
      }
      cout << ans << "\n";
      last = (ans == -1 ? 1 : ans);
    }
  }
}
