#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  in >> p.first >> p.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2>& p) {
  out << p.first << " " << p.second;
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T>& v) {
  for (auto& i : v) {
    out << i << "\n";
  }
  return out;
}
const int MAX = 400007;
int union_find[MAX];
int xorr[MAX];
int Find(int a) {
  if (union_find[a] != a) {
    int temp = Find(union_find[a]);
    xorr[a] ^= xorr[union_find[a]];
    union_find[a] = temp;
  }
  return union_find[a];
}
void Union(int a, int b, int x) {
  int ua = Find(a);
  int ub = Find(b);
  if (ua != ub) {
    xorr[ub] = x ^ xorr[b] ^ xorr[a];
    union_find[ub] = ua;
  }
}
map<int, int> vertices;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  for (int i = (0); i < (MAX); ++i) {
    union_find[i] = i;
  }
  int q;
  cin >> q;
  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;
      l ^= last;
      r ^= last;
      x ^= last;
      if (l > r) {
        swap(l, r);
      }
      ++r;
      int a, b;
      if (vertices.count(l)) {
        a = vertices[l];
      } else {
        int ttt = (int)(vertices.size());
        a = ttt;
        vertices[l] = ttt;
      }
      if (vertices.count(r)) {
        b = vertices[r];
      } else {
        int ttt = (int)(vertices.size());
        b = ttt;
        vertices[r] = ttt;
      }
      Union(a, b, x);
    } else {
      int l, r;
      cin >> l >> r;
      l ^= last;
      r ^= last;
      if (l > r) {
        swap(l, r);
      }
      ++r;
      int prevans;
      if (vertices.count(l) && vertices.count(r)) {
        int a = vertices[l];
        int b = vertices[r];
        if (Find(a) == Find(b)) {
          prevans = xorr[a] ^ xorr[b];
          last = prevans;
        } else {
          prevans = -1;
          last = 1;
        }
      } else {
        prevans = -1;
        last = 1;
      }
      cout << prevans << "\n";
    }
  }
  return 0;
}
