#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int MAXN = 200010;
const int INF = 2147483647;
int fa[MAXN << 1], rel[MAXN << 1];
int idfn;
map<int, int> mp;
inline int id(int x) {
  if (!mp[x]) mp[x] = ++idfn;
  return mp[x];
}
inline pair<int, int> Find(int x) {
  if (fa[x] == x) return make_pair(x, 0);
  pair<int, int> fp = Find(fa[x]);
  fa[x] = fp.first;
  rel[x] ^= fp.second;
  return make_pair(fp.first, rel[x]);
}
int main() {
  for (int i = 1; i < (MAXN << 1); i++) fa[i] = i, rel[i] = 0;
  int Q = read();
  int last = 0;
  while (Q--) {
    int opt = read(), l = read() ^ last, r = read() ^ last;
    if (l > r) swap(l, r);
    if (opt == 1) {
      int x = read() ^ last;
      int idl = id(l - 1), idr = id(r);
      pair<int, int> fal = Find(idl), far = Find(idr);
      rel[fal.first] = fal.second ^ far.second ^ x;
      fa[fal.first] = far.first;
    } else {
      if (!mp[l - 1] || !mp[r] || Find(mp[l - 1]).first != Find(mp[r]).first) {
        puts("-1");
        last = 1;
      } else
        printf("%d\n", last = (Find(mp[l - 1]).second ^ Find(mp[r]).second));
    }
  }
  return 0;
}
