import java.util.*;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
ArrayList ans = new ArrayList<>();
while (t-- != 0) {
int qt = sc.nextInt();
if (qt == 0) {
int aa = sc.nextInt();
ans.add(aa);
} else if (qt == 1) {
int l = sc.nextInt();
int r = sc.nextInt();
int x = sc.nextInt();
int an = 1;
int ii = -1;
for (int i = l - 1; i < r; i++) {
if (an < (x ^ ans.get(i))) {
ii = ans.get(i);
}
}
System.out.println(ii);
}
}
}
}