#include <fstream>
#include <vector>
using namespace std;
#define Maxhash 666013
vector<int>Hash[Maxhash];
void adauga(int x)
{
int rest=x%Maxhash;
unsigned int i=0;
while(i<Hash[rest].size()&&x!=Hash[rest][i])
{
i++;
}
if(i==Hash[rest].size())
{
Hash[rest].push_back(x);
}
}
void sterge(int x)
{
int rest=x%Maxhash;
unsigned int i=0;
while(i<Hash[rest].size()&&x!=Hash[rest][i])
{
i++;
}
if(i<Hash[rest].size())
{
Hash[rest].erase(Hash[rest].begin()+i);
}
}
bool cauta(int x)
{
int rest=x%Maxhash;
unsigned int i=0;
while(i<Hash[rest].size()&&x!=Hash[rest][i])
{
i++;
}
if(i<Hash[rest].size())
{
return 1;
}
return 0;
}
int main()
{
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n,op,x;
fin>>n;
for(int i=1;i<=n;i++)
{
fin>>op>>x;
if(op==1)
{
adauga(x);
}
else if(op==2)
{
sterge(x);
}
else if(op==3)
{
fout<<cauta(x)<<'\n';
}
}
return 0;
}