#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int MOD = 60001;
int N, Type, X;
vector<int> Hash[MOD];
int main()
{
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
scanf("%i", &N);
for(; N; N --)
{
scanf("%i %i", &Type, &X);
if(Type == 1)
{
int Key = X % MOD;
if(find(Hash[Key].begin(), Hash[Key].end(), X) == Hash[Key].end())
Hash[Key].push_back(X);
}else if(Type == 2)
{
int Key = X % MOD;
if(find(Hash[Key].begin(), Hash[Key].end(), X) != Hash[Key].end())
Hash[Key].erase(find(Hash[Key].begin(), Hash[Key].end(), X));
}else
{
int Key = X % MOD;
printf("%i\n", find(Hash[Key].begin(), Hash[Key].end(), X) != Hash[Key].end());
}
}
}