#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
class Treap{
public:
Treap *st,*dr;
int info, priority, weight;
Treap(){
st = dr = 0;
info = priority = 0;
}
Treap(Treap *left, Treap *right, int priority,int info) {
this->st = left;
this->dr = right;
this->priority = priority;
this->info = info;
}
}*Root, *Neal;
void rotateLeft(Treap *&T){
Treap *aux = T->dr;
T->dr = aux->st;
aux->st = T;
T = aux;
}
void rotateRight(Treap *&T){
Treap *aux = T->st;
T->st = aux->dr;
aux->dr = T;
T = aux;
}
void balance(Treap *&T){
if(T->priority < T->st->priority)
rotateRight(T);
else
if(T->priority < T->dr->priority)
rotateLeft(T);
}
bool isIn(Treap *T, int k){
if(T == Neal) /// :D
return false;
if(T->info == k)
return true;
if(k < T->info)
return isIn(T->st, k);
return isIn(T->dr,k);
}
void Insert(Treap *&T, int k, int priority){
if(T == Neal){
T = new Treap(Neal, Neal, priority, k);
return;
}
if(k < T->info)
Insert(T->st, k, priority);
else
Insert(T->dr, k, priority);
}
void Delete(Treap *&T, int k){
if(k < T->info)
Delete(T->st, k);
else
if(k > T->info)
Delete(T->dr, k);
else{
if(T->st == Neal && T->dr == Neal){
Treap *aux = T;
T = Neal;
delete aux;
return;
}
if(T->st->priority > T->dr->priority) {
rotateRight(T);
Delete(T->dr, k);
}
else {
rotateLeft(T);
Delete(T->st, k);
}
}
}
#define DIM 66613
char buffer[DIM];
int poz = DIM - 1;
void scan(int &A)
{
A = 0;
while('0' > buffer[poz] || buffer[poz] > '9')
if(++poz == DIM) fread(buffer,1,DIM,stdin),poz = 0;
while('0' <= buffer[poz] && buffer[poz] <= '9')
{
A = A * 10 + buffer[poz] - 48;
if(++poz == DIM)
fread(buffer,1,DIM,stdin),poz = 0;
}
}
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
srand(time(0));
Neal = new Treap(0,0,-INF,-INF);
Root = Neal;
int N,op,x;
scan(N);
for(int i = 0; i < N; ++i){
scan(op);scan(x);
if(op == 1){
if(isIn(Root, x))
continue;
Insert(Root, x, rand());
continue;
}
if(op == 2){
if(!isIn(Root, x))
continue;
Delete(Root, x);
continue;
}
printf("%d\n",isIn(Root, x));
}
return 0;
}