#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
template <class T>
inline void sort(T &a) {
  sort((a).begin(), (a).end());
}
template <class T>
inline void rsort(T &a) {
  sort((a).rbegin(), (a).rend());
}
template <class T>
inline void reverse(T &a) {
  reverse((a).begin(), (a).end());
}
template <class T, class U>
inline void checkmin(T &x, U y) {
  if (x > y) x = y;
}
template <class T, class U>
inline void checkmax(T &x, U y) {
  if (x < y) x = y;
}
map<int, int> p;
map<int, int> xorp;
void make_set(int x) {
  if (p.count(x)) return;
  p[x] = x;
}
int findset(int x) {
  if (p[x] == x) return x;
  int a = findset(p[x]);
  xorp[x] ^= xorp[p[x]];
  p[x] = a;
  return a;
}
int union_sets(int a, int b, int x) {
  int c = findset(a);
  int d = findset(b);
  x ^= xorp[a] ^ xorp[b];
  if (c != d) {
    if (rand() & 1) {
      p[c] = d;
      xorp[c] = x;
    } else {
      p[d] = c;
      xorp[d] = x;
    }
  }
}
int get(int a, int b) {
  int c = findset(a);
  int d = findset(b);
  if (c != d) return -1;
  return xorp[a] ^ xorp[b];
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(20);
  srand(time(nullptr));
  int q;
  cin >> q;
  int last = 0;
  while (q--) {
    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);
      ++r;
      make_set(l);
      make_set(r);
      union_sets(l, r, x);
    } else {
      int l, r;
      cin >> l >> r;
      l ^= last;
      r ^= last;
      if (l > r) swap(l, r);
      ++r;
      make_set(l);
      make_set(r);
      last = get(l, r);
      cout << last << '\n';
      if (last < 0) last = 1;
    }
  }
  return 0;
}
