#include <bits/stdc++.h>
using namespace std;
int read() {
  int w = 0, f = 1;
  char c = ' ';
  while (c < '0' || c > '9') c = getchar(), f = c == '-' ? -1 : f;
  while (c >= '0' && c <= '9') w = w * 10 + c - 48, c = getchar();
  return w * f;
}
map<int, int> f, w;
int find(int x) {
  if (!f[x]) return x;
  int tmp = find(f[x]);
  w[x] ^= w[f[x]];
  return f[x] = tmp;
}
void update(int l, int r, int v) {
  l--;
  int fl = find(l), fr = find(r);
  if (fl != fr) f[fr] = fl, w[fr] = w[l] ^ w[r] ^ v;
}
int query(int l, int r) {
  l--;
  int fl = find(l), fr = find(r);
  if (fl != fr) return -1;
  return w[l] ^ w[r];
}
signed main() {
  int n = read(), op, l, r, la = 0;
  while (n--) {
    op = read(), l = (read() ^ la) + 2, r = (read() ^ la) + 2;
    if (l > r) swap(l, r);
    if (op == 1)
      update(l, r, read() ^ la);
    else {
      int tmp = query(l, r);
      la = (tmp == -1 ? 1 : tmp);
      printf("%d\n", tmp);
    }
  }
  return 0;
}
