#include <bits/stdc++.h>
using namespace std;
struct Node {
  int d[32];
  int p[32];
  void insert(int x, int pos) {
    for (int i = 30; i >= 0; i--) {
      if (x & (1ll << i)) {
        if (d[i]) {
          if (pos > p[i]) {
            swap(d[i], x);
            swap(p[i], pos);
          }
          x ^= d[i];
        } else {
          d[i] = x;
          p[i] = pos;
          break;
        }
      }
    }
  }
  int query(int pos) {
    int ans = 0;
    for (int i = 30; i >= 0; i--) {
      if (p[i] >= pos) {
        ans = max(ans, d[i] ^ ans);
      }
    }
    return ans;
  }
} Seg[1000100];
int n, m;
void work() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    for (int j = 0; j <= 30; j++) {
      Seg[i].d[j] = Seg[i - 1].d[j];
      Seg[i].p[j] = Seg[i - 1].p[j];
    }
    Seg[i].insert(x, i);
  }
  scanf("%d", &m);
  int nowpos = n;
  int lastans = 0;
  for (int i = 1; i <= m; i++) {
    int opt;
    opt = 0;
    if (opt == 1) {
      nowpos++;
      int x;
      scanf("%d", &x);
      x = x ^ lastans;
      for (int j = 0; j <= 30; j++) {
        Seg[nowpos].d[j] = Seg[nowpos - 1].d[j];
        Seg[nowpos].p[j] = Seg[nowpos - 1].p[j];
      }
      Seg[nowpos].insert(x, i);
    } else {
      int l, r;
      scanf("%d %d", &l, &r);
      if (l > r) swap(l, r);
      lastans = Seg[r].query(l);
      printf("%d\n", lastans);
    }
  }
  for (int i = 0; i <= nowpos; i++)
    for (int j = 0; j <= 30; j++) Seg[i].d[j] = Seg[i].p[j] = 0;
}
int T;
int main() {
  T = 1;
  while (T--) {
    work();
  }
  return 0;
}
