#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> par, dis;
unordered_map<int, int>::iterator i;
int findRep(int n) {
  i = par.find(n);
  if (i == par.end()) return par[n] = n;
  int p = (*i).second;
  if (p == n) return n;
  int r = findRep(p);
  dis[n] ^= dis[p];
  return par[n] = r;
}
void join(int u, int v, int x) {
  int p = findRep(u);
  int q = findRep(v);
  if (p != q) {
    dis[q] = dis[u] ^ dis[v] ^ x;
    par[q] = p;
  }
}
int main() {
  int q, t, l, r, x, last = 0;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d %d %d", &l, &r, &x);
      l ^= last, r ^= last, x ^= last;
      if (l > r) swap(l, r);
      join(l, r + 1, x);
    } else {
      scanf("%d %d", &l, &r);
      l ^= last, r ^= last;
      if (l > r) swap(l, r);
      x = findRep(l) == findRep(r + 1) ? dis[l] ^ dis[r + 1] : -1;
      printf("%d\n", x);
      last = abs(x);
    }
  }
  return 0;
}
