#include <bits/stdc++.h>
using namespace std;
class wunionfind {
 private:
  int *id, *sz, *ans;
  int cnt;
  map<int, int> M;
  vector<vector<int>> adj;
  vector<vector<int>> cost;

 public:
  wunionfind(int n = 400010) {
    cnt = 1;
    id = new int[n + 1];
    sz = new int[n + 1];
    ans = new int[n + 1];
    adj.resize(n + 1);
    cost.resize(n + 1);
    for (int i = 0; i <= n; i++) {
      id[i] = i, sz[i] = 1;
      ans[i] = 0;
    }
  }
  int root(int idx) {
    int i = idx;
    while (i != id[i]) i = id[i];
    return i;
  }
  void dfs(int cur, int par, int x) {
    ans[cur] = ans[par] ^ x;
    for (int i = 0; i < (int)adj[cur].size(); i++) {
      if (adj[cur][i] == par) {
        continue;
      }
      dfs(adj[cur][i], cur, cost[cur][i]);
    }
    return;
  }
  void uni(int a, int b, int x) {
    int i = root(a), j = root(b);
    cost[a].emplace_back(x);
    adj[a].emplace_back(b);
    cost[b].emplace_back(x);
    adj[b].emplace_back(a);
    if (i != j) {
      if (sz[i] >= sz[j]) {
        id[j] = i;
        sz[i] += sz[j];
        sz[j] = 0;
        dfs(b, a, x);
      } else {
        id[i] = j;
        sz[j] += sz[i];
        sz[i] = 0;
        dfs(a, b, x);
      }
    }
  }
  int get(int l, int r) {
    int a = M[l];
    int b = M[r];
    if (!a || !b) {
      return -1;
    }
    if (root(a) != root(b)) {
      return -1;
    }
    return (ans[a] ^ ans[b]);
  }
  void add(int l, int r, int x) {
    if (!M[l]) {
      M[l] = cnt;
      cnt++;
    }
    if (!M[r]) {
      M[r] = cnt;
      cnt++;
    }
    int a = M[l];
    int b = M[r];
    if (root(a) == root(b)) {
      return;
    }
    uni(a, b, x);
  }
} W;
int main() {
  int q;
  scanf("%d", &q);
  int last = 0;
  while (q--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int l, r, x;
      scanf("%d %d  %d", &l, &r, &x);
      l ^= last;
      r ^= last;
      x ^= last;
      if (l > r) {
        swap(l, r);
      }
      r++;
      W.add(l, r, x);
    } else {
      int l, r;
      scanf("%d %d", &l, &r);
      l ^= last;
      r ^= last;
      if (l > r) {
        swap(l, r);
      }
      r++;
      last = W.get(l, r);
      printf("%d\n", last);
      if (last == -1) {
        last = 1;
      }
    }
  }
  return 0;
}
