#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 2;
vector<int> lis[N];
map<int, int> okfine;
int head[N], dis[N], now = 0, pos[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q, i, j, k, l, x, r, last = 0;
  cin >> q;
  for (i = 1; i <= q; i++) {
    cin >> j;
    if (j == 1) {
      cin >> l >> r >> x;
      l = (l ^ last);
      r = (r ^ last);
      if (l > r) {
        swap(l, r);
      }
      x = (x ^ last);
      r++;
      if (!okfine.count(l)) {
        now++;
        okfine[l] = now;
        pos[okfine[l]] = okfine[l];
        lis[now].push_back(okfine[l]);
      }
      if (!okfine.count(r)) {
        now++;
        okfine[r] = now;
        pos[okfine[r]] = okfine[r];
        lis[now].push_back(okfine[r]);
      }
      if (pos[okfine[r]] != pos[okfine[l]]) {
        if (lis[pos[okfine[r]]].size() < lis[pos[okfine[l]]].size()) {
          for (j = 0; j < lis[pos[okfine[r]]].size(); j++) {
            lis[pos[okfine[l]]].push_back(lis[pos[okfine[r]]][j]);
            if (okfine[r] != lis[pos[okfine[r]]][j]) {
              dis[lis[pos[okfine[r]]][j]] = ((dis[lis[pos[okfine[r]]][j]] ^ x) ^
                                             (dis[okfine[l]] ^ dis[okfine[r]]));
              pos[lis[pos[okfine[r]]][j]] = pos[okfine[l]];
            }
          }
          dis[okfine[r]] = (x ^ dis[okfine[l]]);
          pos[okfine[r]] = pos[okfine[l]];
        } else {
          for (j = 0; j < lis[pos[okfine[l]]].size(); j++) {
            lis[pos[okfine[r]]].push_back(lis[pos[okfine[l]]][j]);
            if (okfine[l] != lis[pos[okfine[l]]][j]) {
              dis[lis[pos[okfine[l]]][j]] = ((dis[lis[pos[okfine[l]]][j]] ^ x) ^
                                             (dis[okfine[r]] ^ dis[okfine[l]]));
              pos[lis[pos[okfine[l]]][j]] = pos[okfine[r]];
            }
          }
          dis[okfine[l]] = (x ^ dis[okfine[r]]);
          pos[okfine[l]] = pos[okfine[r]];
        }
      }
    } else {
      cin >> l >> r;
      l = (l ^ last);
      r = (r ^ last);
      if (l > r) {
        swap(l, r);
      }
      r++;
      if (!okfine.count(l)) {
        now++;
        okfine[l] = now;
        pos[okfine[l]] = okfine[l];
        lis[now].push_back(okfine[l]);
      }
      if (!okfine.count(r)) {
        now++;
        okfine[r] = now;
        pos[okfine[r]] = okfine[r];
        lis[now].push_back(okfine[r]);
      }
      if (pos[okfine[l]] != pos[okfine[r]]) {
        cout << -1 << "\n";
        last = 1;
      } else {
        cout << (dis[okfine[l]] ^ dis[okfine[r]]) << "\n";
        last = (dis[okfine[l]] ^ dis[okfine[r]]);
      }
    }
  }
}
