#include <iostream>
#include <fstream>
using namespace std;
const unsigned FNV_offset_basis = 2166136261;
const unsigned FNV_prime = 16777619;
const unsigned NR = 20;
const unsigned MASK = ( 1 << 20 );
const int STERS = -1;
unsigned FNV( unsigned x )
{
unsigned hsh = FNV_offset_basis;
hsh = hsh ^ x;
hsh = hsh * FNV_prime;
return ( hsh & ( MASK - 1 ) );
}
unsigned HT[MASK];
int valid( int pos, int value )
{
return HT[pos] && HT[pos] != value;
}
unsigned position( int value )
{
int pos = FNV( value );
while ( valid( (value + pos) & ( MASK - 1 ), value ) ) pos++;
return (value + pos) & ( MASK - 1 );
}
void insert( int value )
{
HT[ position( value ) ] = value;
}
bool find( int value )
{
return HT[ position( value ) ] == value;
}
void erase( int value )
{
int pos = position( value );
if ( HT[pos] == value ) HT[pos] = -1;
}
int N;
unsigned key, type;
const int DIM_BUFF = ( 1 << 20 );
char buffer[DIM_BUFF];
int position1 = DIM_BUFF;
char GetChar()
{
if ( position1 == DIM_BUFF )
{
fread( buffer, 1, DIM_BUFF, stdin );
position1 = 0;
}
return buffer[ position1++ ];
}
unsigned rd()
{
unsigned nr = 0;
char c;
scanf("%d", &nr);
/*
do
{
c = GetChar();
} while ( !isdigit( c ) );
do
{
nr = nr * 10 + ( c - '0' );
c = GetChar();
} while ( isdigit( c ) );*/
return nr;
}
int main()
{
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
N = rd();
while ( N-- )
{
type = rd(); key = rd();
if ( type == 1 ) insert( key );
if ( type == 2 ) erase( key );
if ( type == 3 ) printf("%d\n", find( key ) );
}
return 0;
}