#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;
vector<int> v[666013];
#define nr 666013
bool findd(int x){
int col = x % nr;
bool ok = false;
int n = v[col].size(), i = 0;
while(i < n && ok == false){
if(v[col][i] == x)
ok = true;
i++;
}
return ok;
}
void add(int x){
bool found = findd(x);
if(found == false)
v[x % nr].push_back(x);
}
void removee(int x){
int col = x % nr;
bool ok = false;
int n = v[col].size(), i = 0;
while(i < n && ok == false){
if(v[col][i] == x)
ok = true;
i++;
}
if(ok == true)
v[col].erase(v[col].begin() + i - 1);
}
int main(){
FILE *fin, *fout;
fin = fopen("hashuri.in", "r");
fout = fopen("hashuri.out", "w");
int no, op;
fscanf(fin, "%d", &no);
for(int i = 0; i < no; i++){
fscanf(fin, "%d", &op);
int x;
fscanf(fin, "%d", &x);
switch(op){
case 1: { add(x);
break;
}
case 2: { removee(x);
break;
}
case 3: { bool res = findd(x);
fprintf(fout, "%d\n", res);
break;
}
default: {}
}
}
}