#include <bits/stdc++.h>
using namespace std;
int q;
int Count = 0;
map<int, int> Map;
int p[600005];
int tk[600005];
vector<int> vec[600005];
int GetID(int x) {
  if (Map.count(x)) return Map[x];
  Map[x] = ++Count;
  p[Count] = Count;
  return Count;
}
int main() {
  int Last = 0;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int u, v, w;
      scanf("%d %d %d", &u, &v, &w);
      u ^= Last;
      v ^= Last;
      w ^= Last;
      if (u > v) swap(u, v);
      v++;
      u = GetID(u);
      v = GetID(v);
      if (p[u] != p[v]) {
        if (vec[p[u]].size() < vec[p[v]].size()) swap(u, v);
        int ww = w ^ tk[v] ^ tk[u];
        tk[p[v]] = ww;
        int pv = p[v];
        for (auto vv : vec[p[v]]) {
          vec[p[u]].push_back(vv);
          p[vv] = p[u];
          tk[vv] = ww ^ tk[vv];
        }
        vec[p[u]].push_back(pv);
        vec[pv].clear();
        p[pv] = p[u];
      }
    } else {
      int u, v;
      scanf("%d %d", &u, &v);
      u ^= Last;
      v ^= Last;
      if (u > v) swap(u, v);
      v++;
      u = GetID(u);
      v = GetID(v);
      if (p[u] == p[v])
        printf("%d\n", tk[u] ^ tk[v]), Last = tk[u] ^ tk[v];
      else
        printf("-1\n"), Last = 1;
    }
  }
}
