#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
map<int, int> idx, Xor[N + 5];
vector<int> v[N + 5];
int par[N + 5];
void init() {
  for (int i = 1; i <= N; ++i) {
    par[i] = i;
    v[i].push_back(i);
    Xor[i][i] = 0;
  }
}
int get_idx(int x) {
  return (idx.find(x) == idx.end() ? idx[x] = idx.size() : idx[x]);
}
int find(int x) { return (x == par[x] ? x : par[x] = find(par[x])); }
void uni(int a, int b, int val) {
  int x = find(a), y = find(b);
  if (v[x].size() < v[y].size()) swap(x, y), swap(a, b);
  par[y] = x;
  for (auto it : v[y]) {
    Xor[b][it] = Xor[it][b] = Xor[b][y] ^ Xor[it][y];
    Xor[x][it] = Xor[it][x] = Xor[it][b] ^ val ^ Xor[a][x];
    v[x].push_back(it);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  init();
  int q, t, l, r, i, j, k, x, y, z, a, b, c;
  int last = 0;
  cin >> q;
  while (q--) {
    cin >> t >> x >> y;
    x = x ^ last;
    y = y ^ last;
    if (x > y) swap(x, y);
    y += 1;
    x = get_idx(x);
    y = get_idx(y);
    if (t == 1) {
      cin >> z;
      z = z ^ last;
      if (find(x) == find(y))
        continue;
      else {
        Xor[x][y] = Xor[y][x] = z;
        uni(x, y, z);
      }
    } else {
      if (find(x) == find(y)) {
        z = find(x);
        last = Xor[x][z] ^ Xor[y][z];
      } else
        last = -1;
      cout << last << endl;
      if (last == -1) last = 1;
    }
  }
  return 0;
}
