#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int M=666013;
vector <int> T[M+5];
vector <int>::iterator it;
int h(int key){
return key%M;
}
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
int n;
int op,x;
scanf("%d",&n);
for(int y=1;y<=n;++y)
{
scanf("%d%d",&op,&x);
int key=h(x);
if(op==1)
T[key].push_back(x);
else
{
it=find(T[key].begin(),T[key].end(),x);
if(op==2){
if(it != T[key].end())
T[key].erase(it);
}
if(op==3){
if(it != T[key].end())
printf("1\n");
else
printf("0\n");
}
}
}
return 0;
}