#include <fstream>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
struct HashTable
{
static const int MOD = 666013;
struct Node
{
int key;
bool val;
};
vector<Node> H[MOD];
inline int h(int key)
{
return key % MOD;
}
vector<Node>::iterator Find(int key)
{
int idx = h(key);
vector<Node>::iterator it;
for(it = H[idx].begin(); it != H[idx].end(); it++)
if(it->key == key)
return it;
return H[idx].end();
}
bool FindKey(int key)
{
int idx = h(key);
return Find(key) != H[idx].end();
}
void InsertKey(int key)
{
int idx = h(key);
vector<Node>::iterator it = Find(key);
if(it == H[idx].end())
H[idx].push_back({.key = key, .val = true});
}
void DeleteKey(int key)
{
int idx = h(key);
vector<Node>::iterator it = Find(key);
if(it != H[idx].end())
H[idx].erase(it);
}
bool& operator[](int key)
{
return Find(key)->val;
}
};
HashTable freq;
void Solve()
{
int q;
fin >> q;
while(q--)
{
int t, x;
fin >> t >> x;
switch(t)
{
case 1:
freq.InsertKey(x);
break;
case 2:
freq.DeleteKey(x);
break;
case 3:
fout << freq.FindKey(x) << '\n';
break;
}
}
}
int main()
{
Solve();
fin.close();
fout.close();
return 0;
}