#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 4e5 + 100;
int par[MAX_N], idSize[MAX_N], xorWeight[MAX_N], timer, last;
map<int, int> ident;
int transSet(int u) {
  if (ident[u] != 0) return ident[u];
  timer++;
  ident[u] = timer;
  return ident[u];
}
int get(int v) {
  if (par[v] != v) {
    int k = par[v];
    par[v] = get(par[v]);
    xorWeight[v] ^= xorWeight[k];
  }
  return par[v];
}
void join(int u, int v, int c) {
  int x1 = u, x2 = v;
  u = get(u), v = get(v);
  if (u == v) return;
  if (idSize[u] < idSize[v]) swap(u, v);
  par[v] = u;
  xorWeight[v] = c ^ xorWeight[x1] ^ xorWeight[x2];
  idSize[u] += idSize[v];
  return;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int q;
  cin >> q;
  for (int i = 0; i <= q; i++) par[i] = i, idSize[i] = 1;
  while (q--) {
    int s, a, b;
    cin >> s >> a >> b;
    if (s == 1) {
      int c;
      cin >> c;
      a ^= last;
      b ^= last;
      c ^= last;
      if (a > b) swap(a, b);
      int timA = transSet(a - 1), timB = transSet(b);
      join(timA, timB, c);
    } else {
      a ^= last;
      b ^= last;
      if (a > b) swap(a, b);
      int u = get(ident[a - 1]), v = get(ident[b]);
      if (u != v || ident[b] == 0 || ident[a - 1] == 0) {
        last = 1;
        cout << -1 << '\n';
      } else {
        last = (xorWeight[ident[a - 1]] ^ xorWeight[ident[b]]);
        cout << last << '\n';
      }
    }
  }
  return 0;
}
