#include <bits/stdc++.h>
using namespace std;
template <class T>
using VV = vector<vector<T>>;
template <class T>
inline T SMIN(T& a, const T b) {
  return a = (a > b) ? b : a;
}
template <class T>
inline T SMAX(T& a, const T b) {
  return a = (a < b) ? b : a;
}
template <class Iter>
void dumpc(Iter begin, Iter end) {
  if (false) {
    for (; begin != end; ++begin) {
      cerr << *begin << ',';
    }
    cerr << endl;
  }
}
int Q;
map<int, int> comp;
int getid(int a) {
  if (comp.count(a)) return comp[a];
  comp[a] = int((comp).size());
  return comp[a];
}
struct UF {
 public:
  int groupNum;
  vector<int> X;
  UF(int N) {
    uf = vector<int>(N);
    rank = vector<int>(N);
    X = vector<int>(N);
    for (int i = 0; i < N; ++i) uf[i] = i, rank[i] = 0;
    groupNum = N;
  }
  int find(int i) { return uf[i] == i ? i : find(uf[i]); }
  int dist(int u) {
    int cur = 0;
    while (uf[u] != u) {
      cur ^= X[u];
      u = uf[u];
    }
    return cur;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  void unite(int x, int y, int z) {
    int px = find(x);
    int py = find(y);
    if (px == py) return;
    groupNum--;
    z = dist(x) ^ dist(y) ^ z;
    if (rank[px] == rank[py]) {
      uf[px] = py;
      X[px] = z;
      rank[py]++;
      return;
    }
    if (rank[px] < rank[py]) {
      uf[px] = py;
      X[px] = z;
    } else {
      uf[py] = px;
      X[py] = z;
      if (rank[px] == rank[py]) ++rank[px];
    }
  }

 private:
  vector<int> rank;
  vector<int> uf;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> Q;
  UF uf(2 * Q + 10);
  int last = 0;
  while (Q--) {
    int t, l, r;
    cin >> t >> l >> r;
    l ^= last, r ^= last;
    if (l > r) swap(l, r);
    ++r;
    if (false) {
      cerr << "l"
           << " = " << (l) << ", "
           << "r"
           << " = " << (r) << ", "
           << "getid(l)"
           << " = " << (getid(l)) << ", "
           << "getid(r)"
           << " = " << (getid(r)) << endl;
    };
    l = getid(l), r = getid(r);
    if (t == 1) {
      int x;
      cin >> x;
      x ^= last;
      uf.unite(l, r, x);
    } else {
      int p1 = uf.find(l), p2 = uf.find(r);
      if (p1 != p2) {
        last = 1;
        fprintf(stdout, "%d", -1), putchar('\n');
        ;
      } else {
        last = uf.dist(l) ^ uf.dist(r);
        fprintf(stdout, "%d", last), putchar('\n');
        ;
      }
    }
  }
  return 0;
}
