#include <iostream>
#include <fstream>
#include <vector>
#define maxL 2000000000
#define prime 11273
using namespace std;
ifstream f("hashuri.in");
ofstream o("hashuri.out");
int main()
{
vector<int> hash[prime];
int n, op, num, rez;
f >> n;
for (int i = 0; i < n; i++)
{
f >> op >> num;
rez = num % prime;
switch (op)
{
case 1:
{
bool exists = 0;
for (vector<int>::iterator i = hash[rez].begin(); i != hash[rez].end(); ++i)
if (*i == num)
exists = 1;
if (!exists)
hash[rez].push_back(num);
break;
}
case 2:
{
for (vector<int>::iterator i = hash[rez].begin(); i != hash[rez].end(); ++i)
{
if (*i == num)
{
hash[rez].erase(i);
break;
}
}
break;
}
case 3:
{
vector<int>::iterator i;
for (i = hash[rez].begin(); i != hash[rez].end(); ++i)
{
if (*i == num)
{
o << 1;
break;
}
}
if (i == hash[rez].end())
o << 0;
o << "\n";
break;
}
}
}
}