#include <fstream>
#include <vector>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
const int MOD = 666014;
vector <int> G[MOD + 2];
int N;
int p, nr;
int Find(int Value)
{
int List = Value % MOD;
for(int i = 0; i < (int)G[List].size(); ++i)
if(G[List][i] == Value)
return i;
return -1;
}
void Insert(int Value)
{
int List = Value % MOD;
if(Find(Value) == -1)
G[List].push_back(Value);
}
void Delete(int Value)
{
int List = Value % MOD,Pos = Find(Value);
if(Pos != -1)
G[List].erase(G[List].begin() + Pos);
}
int main()
{
in >> N;
for(int i = 1; i <= N; ++i){
in >> p >> nr;
if(p == 1)
Insert(nr);
else if(p == 2)
Delete(nr);
else
out << (Find(nr) != -1) << "\n";
}
return 0;
}