#include <fstream>
#include <vector>
#define DIM 999013
using namespace std;
ifstream fin ("hashuri.in" );
ofstream fout("hashuri.out");
int n, m, i, j, k, ok, minim, t, x, y, z, val;
vector<int>::iterator it; vector<int> v[DIM];
vector<int>::iterator position(int x, int y){
vector<int>::iterator it;
for(it = v[y].begin(); it < v[y].end(); it++){
if(x == *it){
return it;
}
}
return it;
}
int main(){
fin >> n;
for(i = 1; i <= n; i++){
fin >> t >> x;
it = position(x, x % DIM);
if(t == 1)
if(it == v[x % DIM].end())
v[x%DIM].push_back(x);
if(t == 2)
if(it != v[x % DIM].end())
v[x%DIM].erase(it);
if(t == 3){
if(it != v[x % DIM].end())
fout << "1\n";
else
fout << "0\n";
}
}
return 0;
}