#include <bits/stdc++.h>
using namespace std;
const int MAXQ = (int)(2e5) + 10;
map<int, pair<int, int>> DSU;
pair<int, int> Find(int u) {
  if (DSU[u].first == u) return DSU[u];
  pair<int, int> path = Find(DSU[u].first);
  path.second ^= DSU[u].second;
  DSU[u] = path;
  return path;
}
void Union(int u, int v, int amt) {
  pair<int, int> paru = Find(u);
  pair<int, int> parv = Find(v);
  if (paru.first == parv.first) return;
  amt ^= paru.second;
  amt ^= parv.second;
  DSU[paru.first] = make_pair(parv.first, amt);
}
int main() {
  int Q;
  scanf("%d", &Q);
  int last = 0;
  while (Q--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int L, R, X;
      scanf("%d %d %d", &L, &R, &X);
      L ^= last;
      R ^= last;
      X ^= last;
      if (L > R) swap(L, R);
      if (DSU.find(L) == DSU.end()) DSU[L] = make_pair(L, 0);
      if (DSU.find(R + 1) == DSU.end()) DSU[R + 1] = make_pair(R + 1, 0);
      Union(L, R + 1, X);
    } else {
      int L, R;
      scanf("%d %d", &L, &R);
      L ^= last;
      R ^= last;
      if (L > R) swap(L, R);
      if (DSU.find(L) == DSU.end()) DSU[L] = make_pair(L, 0);
      if (DSU.find(R + 1) == DSU.end()) DSU[R + 1] = make_pair(R + 1, 0);
      pair<int, int> u = Find(L);
      pair<int, int> v = Find(R + 1);
      if (u.first != v.first) {
        printf("-1\n");
        last = 1;
      } else {
        printf("%d\n", u.second ^ v.second);
        last = u.second ^ v.second;
      }
    }
  }
  return 0;
}
