#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void setmin(T &x, T y) {
  if (y < x) x = y;
}
template <typename T>
inline void setmax(T &x, T y) {
  if (y > x) x = y;
}
template <typename T>
inline T gcd(T a, T b) {
  while (b) swap(a %= b, b);
  return a;
}
const int MAX = 1e6 + 20;
const int INF = 1e9 + 7;
const long long BIG_INF = 1e18 + 5;
long double e = 2.7182818284590452353602874713526624;
long double PI = acos(-1);
long double eps = 1e-19;
long long n, m;
vector<vector<int> > zapytania;
map<int, int> REP;
map<int, int> XOR;
int fajnd(int x) {
  if (REP[x] == x) {
    return x;
  }
  int stary = REP[x];
  int nowy = fajnd(REP[x]);
  XOR[x] ^= XOR[stary];
  REP[x] = nowy;
  return nowy;
}
void onion(int x, int y, int z) {
  int a = fajnd(x);
  int b = fajnd(y);
  z ^= XOR[x];
  z ^= XOR[y];
  if (a == b) {
    return;
  }
  XOR[a] = z;
  REP[a] = b;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  zapytania.resize(n * 2 + 1);
  int last = 0;
  for (int i = 0; i < n; i++) {
    int a, b, c, d;
    cin >> a >> b >> c;
    c ^= last;
    b ^= last;
    if (b > c) {
      swap(b, c);
    }
    c++;
    if (!REP.count(b)) {
      REP[b] = b;
    }
    if (!REP.count(c)) {
      REP[c] = c;
    }
    if (a == 1) {
      cin >> d;
      d ^= last;
      if (fajnd(b) != fajnd(c)) {
        onion(b, c, d);
      }
    } else {
      if (fajnd(b) != fajnd(c)) {
        cout << -1 << '\n';
        last = 1;
      } else {
        last = (XOR[c] ^ XOR[b]);
        cout << last << '\n';
      }
    }
  }
}
