#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
#define mod 666013
vector<int> V[mod];
int find(int x){
int index = x%mod;
for (int i = 0; i < V[index].size();i++){
if (V[index][i] == x){
return 1;
}
}
return 0;
}
void insert(int x){
if (find(x) == 0){
V[x%mod].push_back(x);
}
}
void sterge(int x){
int index = x%mod;
for (int i = 0; i < V[index].size(); i++){
if (V[index][i] == x){
V[index][i] = V[index].back();
V[index].pop_back();
break;
}
}
}
int main(){
fstream f("hashuri.in");
ofstream o("hashuri.out");
int n = 0; f >> n;
int op = 0, x = 0;
for (int i = 0; i < n; i++){
f >> op >> x;
if (op == 1){
insert(x);
continue;
}
if (op == 2){
sterge(x);
continue;
}
o << find(x) << "\n";
}
return 0;
}