#include <bits/stdc++.h>
int q, t, l, r, x, last;
std::map<int, std::pair<int, int>> map;
std::pair<int, int> compress(int x) {
  auto cur = map.find(x);
  if (cur->second.first < 0)
    return std::make_pair(x, 0);
  else {
    auto par = compress(cur->second.first);
    cur->second.second ^= par.second;
    cur->second.first = par.first;
    return cur->second;
  }
}
void connect(int x, int y, int k) {
  auto a = compress(x), b = compress(y);
  if (a.first != b.first) {
    auto u = map.find(a.first), v = map.find(b.first);
    if (u->second.first > v->second.first) {
      std::swap(u, v);
      std::swap(a, b);
    }
    u->second.first += v->second.first;
    v->second.first = a.first;
    v->second.second = k ^ map[x].second ^ map[y].second;
  }
}
int main() {
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  std::ios_base::sync_with_stdio(false);
  std::cin >> q;
  while (q--) {
    std::cin >> t >> l >> r;
    if ((l ^= last) > (r ^= last)) std::swap(l, r);
    if (!map.count(l)) map.insert(std::make_pair(l, std::make_pair(-1, 0)));
    if (!map.count(++r)) map.insert(std::make_pair(r, std::make_pair(-1, 0)));
    if (t == 1) {
      std::cin >> x;
      connect(l, r, x ^ last);
    } else {
      auto x = compress(l), y = compress(r);
      if (x.first != y.first || (x.first < 0 && y.first < 0))
        std::cout << -(last = 1) << '\n';
      else
        std::cout << (last = x.second ^ y.second) << '\n';
    }
  }
}
