#include <bits/stdc++.h>
using namespace std;
const int N = 4 * 100 * 1000 + 5;
map<int, int> par, val;
int FIND(int v) {
  if (par[v] == 0) {
    par[v] = v;
    val[v] = 0;
    return v;
  }
  if (par[v] == v) return v;
  int p = FIND(par[v]);
  val[v] = val[v] ^ val[par[v]];
  par[v] = p;
  return p;
}
int lst;
int l, r, x;
void get1(int _l, int _r, int _x) {
  l = _l ^ lst;
  r = _r ^ lst;
  x = _x ^ lst;
  if (l > r) swap(l, r);
  l++;
  r++;
}
void get2(int _l, int _r) {
  l = _l ^ lst;
  r = _r ^ lst;
  if (l > r) swap(l, r);
  l++;
  r++;
}
int main() {
  int q;
  scanf("%d", &q);
  map<int, int> mp;
  int cnt = 0;
  while (q--) {
    int tp;
    scanf("%d", &tp);
    if (tp == 2) {
      int _l, _r;
      scanf("%d%d", &_l, &_r);
      get2(_l, _r);
      r++;
      int p1 = FIND(l);
      int p2 = FIND(r);
      if (p1 != p2) {
        lst = 1;
        printf("-1\n");
        continue;
      }
      int ans = val[l] ^ val[r];
      printf("%d\n", ans);
      lst = ans;
    } else {
      int _l, _r, _x;
      scanf("%d%d%d", &_l, &_r, &_x);
      get1(_l, _r, _x);
      r++;
      int p1 = FIND(l);
      int p2 = FIND(r);
      if (p1 == p2) continue;
      par[p2] = p1;
      val[p2] ^= x ^ val[r] ^ val[l];
    }
  }
  return 0;
}
