#include<bits/stdc++.h>
using namespace std;

const long long MaxN = 3e5 + 5;

long long q;
multiset<long long> s, t;

void input()
{
    cin >> q;
}

void add(long long x)
{
    auto it = s.lower_bound(x);

    if (it != s.end())
    {
        t.insert(x ^ *it);
    }

    if (it != s.begin())
    {
        auto pre = prev(it);

        if (it != s.end())
        {
            t.erase(t.find(*pre ^ *it));
        }

        t.insert(*pre ^ x);
    }

    s.insert(x);
}

void erase(long long x)
{
    auto it = s.find(x);
    auto pre = it, nxt = it;

    if (it != s.begin())
    {
        pre--;
        t.erase(t.find(*pre ^ x));
    }

    nxt++;

    if (nxt != s.end())
    {
        t.erase(t.find(x ^ *nxt));
    }

    if (it != s.begin() && nxt != s.end())
    {
        t.insert(*pre ^ *nxt);
    }

    s.erase(it);
}

void solve()
{
    while (q--)
    {
        long long type, x;
        cin >> type;

        if (type == 1)
        {
            cin >> x;
            add(x);
        }
        else if (type == 2)
        {
            cin >> x;
            erase(x);
        }
        else
        {
            cout << *t.begin() << "\n";
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    input();
    solve();

    return 0;
}