multiset写的有点答辩)
#include <bits/stdc++.h>
#define int long long
using namespace std;
int read() {
int res = 0;
bool f = false;
char temp = getchar();
for (; !isdigit(temp); temp = getchar()) f = temp == '-';
for (; isdigit(temp); temp = getchar()) res = res * 10 + temp - '0';
return f ? -res : res;
}
multiset<int>s1,s2;
signed main() {
int q = read();
for (int i = 1; i <= q; i++) {
int op = read();
if (op == 1) {
int x = read();
s1.insert(x);
auto item = --s1.upper_bound(x);
auto f = item, b =item;
if (item != s1.begin())
s2.insert(*(--f) ^ *item);
if (item != --s1.end())
s2.insert(*(++b) ^ *item);
if (item != s1.begin() && item != --s1.end())
s2.erase(*f ^ *b);
} else if (op == 2) {
int x = read();
auto item = --s1.upper_bound(x);
auto f = item, b =item;
if (f != s1.begin())
s2.erase(*(--f) ^ *item);
if (b != --s1.end())
s2.erase(*(++b) ^ *item);
if (item != s1.begin() && item != --s1.end())
s2.insert(*f ^ *b);
s1.erase(item);
} else {
cout << *s2.begin() << '\n';
}
}
return 0;
}