#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int inf = numeric_limits<int>::max() / 2;
const long double eps = 1e-9;
const long double pi = acos(-1);
template <typename T>
inline bool mineq(T& a, T b) {
  return (a > b) ? (a = b, 1) : 0;
}
template <typename T>
inline bool maxeq(T& a, T b) {
  return (a < b) ? (a = b, 1) : 0;
}
inline void solve(), read();
const string file = "";
int main() {
  if (file != "") {
    freopen((file + ".in").c_str(), "r", stdin);
    freopen((file + ".out").c_str(), "w", stdout);
  }
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  read();
  solve();
  return 0;
}
struct dsu {
  map<int, int> t, x, rk;
  dsu() {}
  int find(int v) {
    if (!t.count(v)) {
      t[v] = v;
      x[v] = 0;
      rk[v] = 1;
      return v;
    }
    if (t[v] == v) {
      return v;
    }
    int u = find(t[v]);
    x[v] ^= x[t[v]];
    t[v] = u;
    return t[v];
  }
  bool join(int v, int u, int w) {
    v = find(v), u = find(u);
    if (v == u) {
      return 0;
    }
    if (rk[v] > rk[u]) {
      swap(v, u);
    }
    x[u] = w;
    t[u] = v;
    if (rk[v] == rk[u]) {
      ++rk[v];
    }
    return 1;
  }
};
int q;
dsu d;
void query1(int l, int r, int x) {
  int L = d.find(l);
  int R = d.find(r);
  if (L == R) {
    return;
  }
  d.join(L, R, x ^ d.x[l] ^ d.x[r]);
}
int query2(int l, int r) {
  int L = d.find(l);
  int R = d.find(r);
  if (L != R) {
    return -1;
  }
  int ans = d.x[l] ^ d.x[r];
  return ans;
}
inline void solve() {
  int last = 0;
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      int l_, r_, x_;
      cin >> l_ >> r_ >> x_;
      int l = l_ ^ last;
      int r = r_ ^ last;
      int x = x_ ^ last;
      if (l > r) {
        swap(l, r);
      }
      ++r;
      query1(l, r, x);
    } else if (t == 2) {
      int l_, r_;
      cin >> l_ >> r_;
      int l = l_ ^ last;
      int r = r_ ^ last;
      if (l > r) {
        swap(l, r);
      }
      ++r;
      int ans = query2(l, r);
      last = ans;
      if (ans == -1) {
        last = 1;
      }
      cout << ans << "\n";
    }
  }
}
inline void read() { cin >> q; }
