#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> p, x;
int find(int u) {
  auto it = p.find(u);
  if (it == p.end()) {
    x[u] = 0;
    return u;
  }
  int v = it->second, vv = find(v);
  x[u] ^= x[v];
  return p[u] = vv;
}
void unite(int u, int v, int val) {
  int a = find(u), b = find(v);
  if (a == b) return;
  p[a] = b;
  x[a] = x[u] ^ x[v] ^ val;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int q, last = 0;
  cin >> q;
  while (q--) {
    int t, l, r;
    cin >> t >> l >> r;
    l ^= last, r ^= last;
    if (l > r) swap(l, r);
    r++;
    if (t == 1) {
      int val;
      cin >> val;
      val ^= last;
      unite(l, r, val);
    } else {
      int a = find(l), b = find(r);
      if (a != b)
        last = -1;
      else
        last = x[l] ^ x[r];
      cout << last << '\n';
      last = abs(last);
    }
  }
}
