#include <bits/stdc++.h>
using namespace std;
map<int, int> a, b;
int k;
int t(int x) {
  if (a.count(x) == 0) return x;
  int s = a[x];
  if (s == x) return x;
  a[x] = t(s);
  b[x] ^= b[s];
  return a[x];
}
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int o, l, r;
    scanf("%d%d%d", &o, &l, &r);
    l ^= k;
    r ^= k;
    if (l > r) swap(l, r);
    if (o == 1) {
      int x;
      scanf("%d", &x);
      x ^= k;
      r++;
      int f = t(l);
      int g = t(r);
      if (f != g) {
        a[f] = g;
        b[f] = b[l] ^ b[r] ^ x;
      }
    } else {
      r++;
      int f = t(l), g = t(r);
      if (f != g)
        k = -1;
      else
        k = b[l] ^ b[r];
      printf("%d\n", k);
      if (k == -1) k = 1;
    }
  }
  return 0;
}
