#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
inline void ckmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void ckmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
unordered_map<int, int> f;
unordered_map<int, int> d;
int getf(int p) {
  if (!f.count(p)) {
    f[p] = -1;
    d[p] = 0;
  }
  if (f[p] < 0) return p;
  int r = getf(f[p]);
  d[p] ^= d[f[p]];
  f[p] = r;
  return r;
}
void update(int l, int r, int x) {
  ++r;
  int a = getf(l);
  int b = getf(r);
  if (a != b) {
    if (rand() & 1) swap(a, b);
    f[a] = b;
    d[a] = d[l] ^ d[r] ^ x;
  }
}
int solve(int l, int r) {
  ++r;
  int a = getf(l);
  int b = getf(r);
  if (a != b) return -1;
  return d[l] ^ d[r];
}
int main() {
  std::ios::sync_with_stdio(false);
  int nq;
  while (cin >> nq) {
    f.clear();
    d.clear();
    int last = 0;
    for (int cl = 0; cl < (nq); ++cl) {
      int t;
      cin >> t;
      if (t == 1) {
        int l, r, x;
        cin >> l >> r >> x;
        l ^= last;
        r ^= last;
        x ^= last;
        if (l > r) swap(l, r);
        update(l, r, x);
      } else {
        int l, r;
        cin >> l >> r;
        l ^= last;
        r ^= last;
        if (l > r) swap(l, r);
        int ret = solve(l, r);
        printf("%d\n", ret);
        if (ret == -1)
          last = 1;
        else
          last = ret;
      }
    }
    break;
  }
  return 0;
}
