#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200001;
static int Q, G = 1;
static struct tUF { int p, v; } uf[MAXN << 1];
static map<int, int> p2uf;
tUF findUf(int x) {
  if (uf[x].p != x) {
    auto tmp = findUf(uf[x].p);
    uf[x].p = tmp.p;
    uf[x].v ^= tmp.v;
  }
  return uf[x];
}
inline int getUf(int pos) {
  if (!p2uf[pos]) {
    uf[G].p = G;
    return p2uf[pos] = G++;
  } else
    return p2uf[pos];
}
int main() {
  scanf("%d", &Q);
  for (int last = 0; Q--;) {
    int t, l, r, x;
    scanf("%d%d%d", &t, &l, &r);
    l ^= last;
    r ^= last;
    if (l > r) swap(l, r);
    if (t == 1) {
      scanf("%d", &x);
      auto _l = findUf(getUf(l)), _r = findUf(getUf(r + 1));
      if (_l.p == _r.p) continue;
      uf[_l.p] = {_r.p, _l.v ^ _r.v ^ x ^ last};
    } else {
      auto _l = findUf(getUf(l)), _r = findUf(getUf(r + 1));
      printf("%d\n", last = (_l.p != _r.p ? -1 : _l.v ^ _r.v));
      last = abs(last);
    }
  }
  return 0;
}
