#include <fstream>
#include <list>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
long N, tip, x, i;
list<long> lista;
list<long>::iterator it;
int cautare(int x,bool op){
for( it=lista.begin() ; it != lista.end() ; it++)
if((*it)==x){
if(!op) lista.erase(it);
return 1;
}
return 0;
}
int main()
{
f >> N;
for( i=1; i <= N ; i++){
f >> tip >> x;
switch( tip ){
case 1:
if(!cautare(x,0))
lista.push_back(x);
break;
case 2:
1 << cautare(x,1);
break;
case 3:
if(cautare(x,0))
g << "1\n";
else
g << "0\n";
break;
}
}
}