#include <bits/stdc++.h>
using namespace std;
vector<long long> previous, height;
vector<vector<long long>> weight;
unordered_map<long long, long long> indexes;
long long new_index = 0;
long long get_index(long long x) {
  if (!indexes.count(x)) {
    indexes[x] = new_index;
    previous.push_back(new_index);
    height.push_back(1);
    weight.push_back({0, 0});
    new_index += 1;
  }
  return indexes[x];
}
long long find_set(long long v) {
  if (v == previous[v]) return v;
  long long p = find_set(previous[v]);
  weight[v][0] = weight[previous[v]][0] ^ weight[v][1];
  weight[v][1] = weight[v][0];
  previous[v] = p;
  return p;
}
void unite(long long v, long long u, long long x) {
  long long a = find_set(v), b = find_set(u);
  if (a == b) return;
  if (height[a] < height[b]) {
    swap(a, b);
    swap(v, u);
  }
  previous[b] = a;
  weight[b][0] = weight[v][0] ^ weight[u][0] ^ x;
  weight[b][1] = weight[b][0];
  if (height[a] == height[b]) height[a] += 1;
}
signed main() {
  long long last = 0;
  long long Q;
  cin >> Q;
  while (Q--) {
    long long type;
    cin >> type;
    long long left, right;
    cin >> left >> right;
    left ^= last;
    right ^= last;
    if (left > right) swap(left, right);
    right += 1;
    left = get_index(left);
    right = get_index(right);
    if (type == 1) {
      long long x;
      cin >> x;
      x ^= last;
      if (find_set(left) != find_set(right)) unite(left, right, x);
    } else {
      if (find_set(left) != find_set(right)) {
        cout << "-1\n";
        last = 1;
      } else {
        last = weight[left][0] ^ weight[right][0];
        cout << last << "\n";
      }
    }
  }
}
