#include <bits/stdc++.h>
#define ll long long
#define sz size
#define pb push_back
#define er erase
#define in insert
#define fr first
#define sc second
#define mp make_pair
#define pi pair
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
#define rc(s) return cout<<s,0
const int mod=1e9+7;
const int inf=1e5;
const int huh=6e5;
using namespace std;
std::vector<int>::iterator it;
vector<int>lel[huh];
int n;
int x;
int t;
bool lol;
bool findo(int y){
for(int i=0;i<lel[y%huh].size();i++){
if(lel[y%huh][i]==y) return true;
}
return false;
}
int main(){
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
fin >> n;
for(int i=1;i<=n;i++){
fin >> t >> x;
int you=x%huh;
if(t==1){
if(findo(x)==false)lel[you].push_back(x);
continue;
}
if(t==2){
it=lel[you].begin();
while(it!=lel[you].end()){
if(*it==x){ lel[you].erase(it); break; }
it++;
}
}
if(t==3){
lol=true;
for(int j=0;j<lel[you].size();j++){
if(lel[you][j]==x){fout<<1<<endl; lol=false; break;}
}
if(lol==true) fout<<0<<endl;
}
}
}