#include <bits/stdc++.h>
using namespace std;
const int maxq = 4e5;
int fa[maxq + 5], val[maxq + 5];
inline void build() {
  for (int i = 1; i <= maxq; ++i) fa[i] = i;
}
int root(const int u) {
  if (fa[u] == u) return u;
  int t = root(fa[u]);
  val[u] ^= val[fa[u]];
  return fa[u] = t;
}
inline int getval(const int x) {
  root(x);
  return val[x];
}
inline void Merge(const int u, const int v, const int x) {
  if (root(u) == root(v)) return;
  int fu = root(u), fv = root(v);
  val[fv] = val[u] ^ val[v] ^ x;
  fa[fv] = fu;
}
inline int Getans(const int u, const int v) {
  if (!u || !v || root(u) != root(v)) return -1;
  return getval(u) ^ getval(v);
}
map<int, int> MP;
int cnt;
int q;
int ans, last;
int main() {
  scanf("%d", &q);
  build();
  int opt, l, r, x;
  while (q--) {
    scanf("%d%d%d", &opt, &l, &r);
    l ^= last, r ^= last;
    if (l > r) swap(l, r);
    --l;
    if (opt == 1) {
      scanf("%d", &x);
      x ^= last;
      if (MP[l] == 0) MP[l] = ++cnt;
      if (MP[r] == 0) MP[r] = ++cnt;
      Merge(MP[l], MP[r], x);
    } else {
      ans = Getans(MP[l], MP[r]);
      last = (ans == -1 ? 1 : ans);
      printf("%d\n", ans);
    }
  }
  return 0;
}
