#include <bits/stdc++.h>
using namespace std;
map<int, int> X, pre;
map<int, int>::iterator it;
int Find(int u) {
  it = pre.find(u);
  if (it == pre.end()) {
    X[u] = 0;
    return u;
  }
  int v = it->second;
  int tmp = Find(v);
  X[u] ^= X[v];
  return pre[u] = tmp;
}
bool join(int a, int b, int x) {
  int c = Find(a), d = Find(b);
  if (c == d) return false;
  pre[d] = c;
  X[d] = X[a] ^ X[b] ^ x;
  return true;
}
int main() {
  int q, last = 0;
  scanf("%d", &q);
  while (q--) {
    int tp, a, b;
    scanf("%d%d%d", &tp, &a, &b);
    a ^= last;
    b ^= last;
    if (a > b) swap(a, b);
    b++;
    if (tp == 1) {
      int x;
      scanf("%d", &x);
      join(a, b, x ^ last);
    } else {
      if (Find(a) != Find(b))
        last = -1;
      else
        last = X[a] ^ X[b];
      printf("%d\n", last);
      last = abs(last);
    }
  }
  return 0;
}
