#include <bits/stdc++.h>
#pragma comment(linker, "/stack:16777216")
using namespace std;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000;
const long long LINF = INF * (long long)INF;
const int MAX = 500007;
const int MAX1 = 2007;
const int MAX2 = 24000000;
const int LEN = 21;
const int MOD = 998244353;
map<int, int> M;
vector<int> A[MAX];
int V[MAX];
int ID[MAX];
int get_mappping(int x) {
  if (M.count(x)) return M[x];
  int sz = (int)M.size();
  M[x] = sz;
  return sz;
}
int main() {
  int q;
  cin >> q;
  for (int i = (0); i < (MAX); ++i) {
    A[i].push_back(i);
    ID[i] = i;
  }
  int last = 0;
  for (int qq = (0); qq < (q); ++qq) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int l, r, x;
      scanf("%d%d%d", &l, &r, &x);
      l ^= last;
      r ^= last;
      x ^= last;
      if (l > r) swap(l, r);
      ++r;
      l = get_mappping(l);
      r = get_mappping(r);
      if (ID[l] == ID[r]) {
        continue;
      }
      int idl = ID[l];
      int idr = ID[r];
      if ((int)A[idl].size() < (int)A[idr].size()) {
        swap(idl, idr);
        swap(l, r);
      }
      int xv = (V[l] ^ V[r] ^ x);
      for (int i = (0); i < ((int)A[idr].size()); ++i) {
        int x = A[idr][i];
        A[idl].push_back(x);
        ID[x] = idl;
        V[x] ^= xv;
      }
      {
        vector<int> temp;
        temp.swap(A[idr]);
      }
    } else {
      int l, r;
      scanf("%d%d", &l, &r);
      l ^= last;
      r ^= last;
      if (l > r) swap(l, r);
      ++r;
      l = get_mappping(l);
      r = get_mappping(r);
      if (ID[l] == ID[r]) {
        int res = (V[l] ^ V[r]);
        last = res;
        printf("%d\n", res);
      } else {
        last = 1;
        printf("-1\n");
      }
    }
  }
  return 0;
}
