#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  Solution() : last(0) {}
  void update(int l, int r, int x) {
    l ^= last;
    r ^= last;
    x ^= last;
    if (l > r) {
      swap(l, r);
    }
    ++r;
    auto pl = find(l);
    auto pr = find(r);
    if (pl.first == pr.first) {
      return;
    }
    if (pl.first > pr.first) {
      swap(pl, pr);
    }
    par[pr.first] = make_pair(pl.first, pl.second ^ pr.second ^ x);
  }
  int query(int l, int r) {
    l ^= last;
    r ^= last;
    if (l > r) {
      swap(l, r);
    }
    ++r;
    auto pl = find(l);
    auto pr = find(r);
    if (pl.first == pr.first) {
      last = pl.second ^ pr.second;
      return last;
    } else {
      last = 1;
      return -1;
    }
  }

 private:
  map<int, pair<int, int>> par;
  int last;
  pair<int, int> find(int x) {
    if (par.count(x) == 0) {
      par[x] = make_pair(x, 0);
    } else if (par[x].first != x) {
      auto p = find(par[x].first);
      par[x].second ^= p.second;
      par[x].first = p.first;
    }
    return par[x];
  }
};
int main(int argc, char** argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Solution sol;
  int q;
  cin >> q;
  while (q-- > 0) {
    int t, l, r, x;
    cin >> t;
    if (t == 1) {
      cin >> l >> r >> x;
      sol.update(l, r, x);
    } else {
      cin >> l >> r;
      cout << sol.query(l, r) << endl;
    }
  }
  return 0;
}
