#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
#define Nmode 15777
int n,task,x;
vector <int> v[Nmode];
int Find(int x)
{
int l=x%Nmode,ok=0;
vector <int> ::iterator it;
for(it=v[l].begin();it!=v[l].end();it++)
{
if(*it==x)
{
ok=1;
break;
}
}
return ok;
}
void Insert(int x)
{
int l=x%Nmode;
if(!Find(x))
v[l].push_back(x);
}
void Erase(int x)
{
int l=x%Nmode;
vector <int> ::iterator it;
for(it=v[l].begin();it!=v[l].end();it++)
{
if(*it==x)
{
v[l].erase(it);
break;
}
}
}
int main()
{
fin>>n;
for(int i=1;i<=n;i++)
{
fin>>task>>x;
switch(task)
{
case 1:
{
if(!Find(x))
Insert(x);
break;
}
case 2:
{
Erase(x);
break;
}
case 3:
{
fout<<Find(x)<<'\n';
break;
}
}
}
}