#include <bits/stdc++.h>
using namespace std;
int z = 1000000007;
map<int, int> parent;
map<int, int> XOR;
pair<long long int, long long int> finding(int n, int xo) {
  if (parent.find(n) == parent.end())
    return pair<long long int, long long int>(n, 0);
  pair<long long int, long long int> temp = finding(parent[n], 0);
  int pa = temp.first;
  parent[n] = pa;
  XOR[n] = (temp.second) ^ XOR[n];
  return pair<long long int, long long int>(parent[n], XOR[n]);
}
void unite(int a, int b, int xo) {
  parent[a] = b;
  XOR[a] = xo;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  int ans = 0;
  for (int i = 1; i <= q; i++) {
    int op;
    cin >> op;
    if (op == 1) {
      int l, r, x;
      cin >> l >> r >> x;
      l = l ^ ans;
      r = r ^ ans;
      if (l > r) swap(l, r);
      r = r + 1;
      x = x ^ ans;
      int xl = 0, xr = 0;
      pair<long long int, long long int> temp = finding(l, xl);
      int nl = temp.first;
      xl = temp.second;
      temp = finding(r, xr);
      int nr = temp.first;
      xr = temp.second;
      if (nl != nr) unite(nl, nr, ((xl ^ xr) ^ x));
    } else {
      int l, r;
      cin >> l >> r;
      l = l ^ ans;
      r = r ^ ans;
      if (l > r) swap(l, r);
      r = r + 1;
      int xl = 0, xr = 0;
      pair<long long int, long long int> temp = finding(l, xl);
      int nl = temp.first;
      xl = temp.second;
      temp = finding(r, xr);
      int nr = temp.first;
      xr = temp.second;
      if (nl == nr) {
        cout << (xl ^ xr) << endl;
        ans = (xl ^ xr);
      } else {
        ans = 1;
        cout << -1 << endl;
      }
    }
  }
  return 0;
}
