#include <bits/stdc++.h>
using namespace std;
const int N = 8e5 + 10;
struct spl {
  int son[2], val, tag, sum, fa;
} tree[N];
int is_not_root(int o) {
  return (tree[tree[o].fa].son[0] == o || tree[tree[o].fa].son[1] == o);
}
int which_son(int o) {
  if (tree[tree[o].fa].son[0] == o) return 0;
  return 1;
}
void SWAP(int o) {
  swap(tree[o].son[0], tree[o].son[1]);
  tree[o].tag ^= 1;
}
void pushup(int o) {
  tree[o].sum =
      tree[tree[o].son[0]].sum ^ tree[tree[o].son[1]].sum ^ tree[o].val;
}
void pushdown(int o) {
  if (tree[o].tag == 1) {
    tree[o].tag = 0;
    if (tree[o].son[0]) SWAP(tree[o].son[0]);
    if (tree[o].son[1]) SWAP(tree[o].son[1]);
  }
}
void rotate(int o) {
  int fa = tree[o].fa;
  int g_fa = tree[fa].fa;
  int wt = which_son(o);
  int son = tree[o].son[wt ^ 1];
  if (is_not_root(fa)) {
    tree[g_fa].son[which_son(fa)] = o;
  }
  tree[o].fa = g_fa;
  tree[fa].fa = o;
  tree[o].son[wt ^ 1] = fa;
  tree[fa].son[wt] = son;
  if (son) tree[son].fa = fa;
  pushup(fa);
}
int st[10000010], top;
void splay(int o) {
  top = 0;
  int now = o;
  st[++top] = o;
  while (is_not_root(now)) now = tree[now].fa, st[++top] = now;
  while (top) pushdown(st[top]), --top;
  while (is_not_root(o)) {
    int fa = tree[o].fa;
    if (!is_not_root(fa)) {
      rotate(o);
    } else {
      if (which_son(o) == which_son(fa)) {
        rotate(fa);
        rotate(o);
      } else {
        rotate(o);
        rotate(o);
      }
    }
  }
  pushup(o);
}
void access(int o) {
  for (int x = 0; o; x = o, o = tree[o].fa) {
    splay(o);
    tree[o].son[1] = x;
    pushup(o);
  }
}
void makeroot(int o) {
  access(o);
  splay(o);
  SWAP(o);
}
int findroot(int o) {
  access(o);
  splay(o);
  while (tree[o].son[0]) pushdown(o), o = tree[o].son[0];
  splay(o);
  return o;
}
void spilt(int x, int y) {
  makeroot(x);
  access(y);
  splay(y);
}
void link(int x, int y) {
  makeroot(x);
  if (findroot(y) != x) tree[x].fa = y;
}
void cut(int x, int y) {
  makeroot(x);
  if (findroot(y) == x && tree[y].son[0] == 0 && tree[y].fa == x) {
    tree[y].fa = 0;
    tree[x].son[1] = 0;
    pushup(x);
  }
}
int n, m, num;
map<int, int> ma;
int main() {
  int q;
  scanf("%d", &q);
  int ans = 0;
  while (q--) {
    int op, l, r;
    scanf("%d%d%d", &op, &l, &r);
    l ^= ans;
    r ^= ans;
    if (l > r) swap(l, r);
    if (op == 1) {
      int x;
      scanf("%d", &x);
      x ^= ans;
      if (ma[l - 1] == 0) ma[l - 1] = ++n;
      if (ma[r] == 0) ma[r] = ++n;
      link(ma[l - 1], ++n);
      link(ma[r], n);
      tree[n].val = x;
    } else {
      if (ma[l - 1] == 0 || ma[r] == 0)
        printf("-1\n"), ans = -1;
      else {
        if (findroot(ma[l - 1]) != findroot(ma[r]))
          printf("-1\n"), ans = -1;
        else {
          spilt(ma[l - 1], ma[r]);
          printf("%d\n", ans = tree[ma[r]].sum);
        }
      }
    }
    if (ans == -1) ans = 1;
  }
}
