#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 400005;
const int BITS = 31;
int trie[MAXN * 32][2], tot;
int pre[MAXN], leftMax[MAXN], rightMax[MAXN];
void insert(int x) {
int node = 0;
for (int i = BITS - 1; i >= 0; i--) {
int bit = (x >> i) & 1;
if (!trie[node][bit]) {
trie[node][bit] = ++tot;
}
node = trie[node][bit];
}
}
int query(int x) {
int node = 0, res = 0;
for (int i = BITS - 1; i >= 0; i--) {
int bit = (x >> i) & 1;
if (trie[node][bit ^ 1]) {
res |= (1 << i);
node = trie[node][bit ^ 1];
} else {
node = trie[node][bit];
}
}
return res;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}