#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
map<int, int> par, f;
int anc(int u) {
  if (par.find(u) == par.end()) return u;
  int p = par[u];
  par[u] = anc(p);
  f[u] ^= f[p];
  return par[u];
}
void join(int u, int v, int val) {
  int pu = anc(u), pv = anc(v);
  if (pu == pv) return;
  par[pv] = pu;
  f[pv] = val ^ f[u] ^ f[v];
}
int qry(int u, int v) {
  int pu = anc(u), pv = anc(v);
  return (pu == pv ? f[u] ^ f[v] : -1);
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int last = 0, q;
  cin >> q;
  while (q--) {
    int type;
    cin >> type;
    if (type == 1) {
      int l, r, v;
      cin >> l >> r >> v;
      l ^= last, r ^= last, v ^= last;
      if (l > r) swap(l, r);
      r++;
      join(l, r, v);
    } else {
      int l, r;
      cin >> l >> r;
      l ^= last, r ^= last;
      if (l > r) swap(l, r);
      r++;
      int ans = qry(l, r);
      last = abs(ans);
      cout << ans << '\n';
    }
  }
  return 0;
}
