#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& st, pair<S, T> p) {
  st << "(" << p.first << "," << p.second << ")";
  return st;
}
template <class T>
ostream& operator<<(ostream& st, vector<T> v) {
  st << "[";
  for (size_t i = 0; i < v.size(); ++i) {
    if (i != 0) {
      st << ", ";
    }
    st << v[i];
  }
  st << "]";
  return st;
}
pair<int, int> get_parent_dsu(int v, vector<pair<int, int> >& parents) {
  if (parents[v].first != v) {
    pair<int, int> p = get_parent_dsu(parents[v].first, parents);
    parents[v] = make_pair(p.first, p.second ^ parents[v].second);
  }
  return parents[v];
}
void union_dsu(int a, int b, int value, vector<int>& mass,
               vector<pair<int, int> >& parents) {
  pair<int, int> a_parent = get_parent_dsu(a, parents);
  pair<int, int> b_parent = get_parent_dsu(b, parents);
  a = a_parent.first;
  int a_dist = a_parent.second;
  b = b_parent.first;
  int b_dist = b_parent.second;
  if (a != b) {
    if (mass[a] > mass[b]) {
      swap(a, b);
      swap(a_dist, b_dist);
    }
    parents[a].first = b;
    parents[a].second = value ^ a_dist ^ b_dist;
    mass[b] += mass[a];
  }
}
int perform_get_query(int a, int b, vector<pair<int, int> >& parents) {
  pair<int, int> a_parent = get_parent_dsu(a, parents);
  pair<int, int> b_parent = get_parent_dsu(b, parents);
  int result;
  if (a_parent.first == b_parent.first) {
    result = a_parent.second ^ b_parent.second;
  } else {
    result = -1;
  }
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  int q;
  cin >> q;
  int mapper_size = 0;
  map<int, int> mapper;
  vector<int> mass;
  vector<pair<int, int> > parents_dsu;
  int last = 0;
  for (int i = 0; i < q; ++i) {
    int t;
    cin >> t;
    int l, r, value;
    cin >> l >> r;
    l = l ^ last;
    r = r ^ last;
    if (l > r) {
      swap(l, r);
    }
    --l;
    if (mapper.count(l) == 0) {
      mass.push_back(1);
      parents_dsu.push_back(make_pair(mapper_size, 0));
      mapper[l] = mapper_size++;
    }
    if (mapper.count(r) == 0) {
      mass.push_back(1);
      parents_dsu.push_back(make_pair(mapper_size, 0));
      mapper[r] = mapper_size++;
    }
    int a = mapper[l];
    int b = mapper[r];
    if (t == 1) {
      cin >> value;
      value = last ^ value;
      union_dsu(a, b, value, mass, parents_dsu);
    } else {
      last = perform_get_query(a, b, parents_dsu);
      cout << last << endl;
      if (last == -1) {
        last = 1;
      }
    }
  }
  return 0;
}
