#include <fstream>
#include <vector>
using namespace std;
#define MOD 914239
vector<vector<int> >has(MOD);
vector<int> ::iterator find(int x)
{
vector<int> :: iterator it;
int list=x%MOD;
for(it=has[list].begin();it!=has[list].end();it++)
if(*it==x)return it;
return has[list].end();
}
void add(int x)
{
int list=x%MOD;
if(find(x)==has[list].end())
has[list].push_back(x);
}
int del(int x)
{
int list = x % MOD;
vector<int>::iterator it=find(x);
if (it != has[list].end())
has[list].erase(it);
}
int main()
{
ifstream be("hashuri.in");
ofstream ki("hashuri.out");
int n;
be>>n;
for(int i=1;i<=n;i++)
{
int x,y;
be>>x>>y;
if(x==1){
add(y);
}
if(x==2)del(y);
if(x==3)
{
ki<<(find(y)!=has[y%MOD].end())<<endl;
}
}
return 0;
}