#include <bits/stdc++.h>
using namespace std;
const int N = 400005;
map<int, int> go;
int get_id(int x) {
  if (go.count(x)) return go[x];
  return go[x] = (int)go.size();
}
int p[N], sz[N];
int to[N];
int f(int u) { return u == p[u] ? u : f(p[u]); }
int get(int u) { return u == p[u] ? 0 : to[u] ^ get(p[u]); }
int main() {
  iota(p, p + N, 0);
  for (int i = 0; i < N; i++) sz[i] = 1;
  int q;
  scanf("%d", &q);
  int last = 0;
  while (q--) {
    int t, l, r, x;
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d %d %d", &l, &r, &x);
      l ^= last, r ^= last, x ^= last;
      if (l > r) swap(l, r);
      r++;
      l = get_id(l), r = get_id(r);
      x ^= get(l) ^ get(r);
      l = f(l), r = f(r);
      if (l == r) continue;
      if (sz[l] > sz[r]) swap(l, r);
      to[l] = x;
      p[l] = r;
      sz[r] += sz[l];
    } else {
      scanf("%d %d", &l, &r);
      l ^= last, r ^= last;
      if (l > r) swap(l, r);
      r++;
      l = get_id(l), r = get_id(r);
      if (f(l) != f(r)) {
        printf("-1\n");
        last = 1;
      } else {
        printf("%d\n", last = (get(l) ^ get(r)));
      }
    }
  }
}
