#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
pair<int, int> p[2 * N];
map<int, int> ma;
int cnt, s[2 * N];
void upd(int l, int r, int x) {
  r++;
  map<int, int>::iterator it;
  it = ma.find(l);
  if (it == ma.end()) {
    cnt++;
    p[cnt] = make_pair(cnt, 0);
    s[cnt] = 1;
    ma.insert(make_pair(l, cnt));
  }
  it = ma.find(r);
  if (it == ma.end()) {
    cnt++;
    p[cnt] = make_pair(cnt, 0);
    s[cnt] = 1;
    ma.insert(make_pair(r, cnt));
  }
  l = ma[l];
  r = ma[r];
  int w1 = 0, w2 = 0;
  while (l != p[l].first) {
    w1 ^= p[l].second;
    l = p[l].first;
  }
  while (r != p[r].first) {
    w2 ^= p[r].second;
    r = p[r].first;
  }
  if (l == r) {
    return;
  }
  if (s[l] > s[r]) {
    p[r] = make_pair(l, x ^ w1 ^ w2);
    s[l] += s[r];
  } else {
    p[l] = make_pair(r, x ^ w1 ^ w2);
    s[r] += s[l];
  }
}
int get(int l, int r) {
  r++;
  map<int, int>::iterator it;
  it = ma.find(l);
  if (it == ma.end()) {
    cnt++;
    p[cnt] = make_pair(cnt, 0);
    s[cnt] = 1;
    ma.insert(make_pair(l, cnt));
  }
  it = ma.find(r);
  if (it == ma.end()) {
    cnt++;
    p[cnt] = make_pair(cnt, 0);
    s[cnt] = 1;
    ma.insert(make_pair(r, cnt));
  }
  l = ma[l];
  r = ma[r];
  int w1 = 0, w2 = 0;
  while (l != p[l].first) {
    w1 ^= p[l].second;
    l = p[l].first;
  }
  while (r != p[r].first) {
    w2 ^= p[r].second;
    r = p[r].first;
  }
  if (l != r) {
    return -1;
  }
  return w1 ^ w2;
}
int main() {
  ios_base::sync_with_stdio(0);
  int q;
  cin >> q;
  int last = 0;
  for (int i = 1; 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);
      }
      upd(l, r, x);
    }
    if (t == 2) {
      int l, r;
      cin >> l >> r;
      l ^= last;
      r ^= last;
      if (l > r) {
        swap(l, r);
      }
      int ans = get(l, r);
      cout << ans << "\n";
      last = ans;
      if (ans == -1) {
        last = 1;
      }
    }
  }
  return 0;
}
