#include <bits/stdc++.h>
using namespace std;
const int MAX_SIZE = 1 << 21;
const int MASK = MAX_SIZE - 1;
const int EMPTY = -1;
const int ERASED = -2;
int table[MAX_SIZE];
void insert(const int key)
{
int p = (91 * key) & MASK;
while (table[p] != key && table[p] != EMPTY && table[p] != ERASED)
p = (p + 1) & MASK;
table[p] = key;
}
bool find(const int key)
{
int p = (91 * key) & MASK;
while (table[p] != key && table[p] != EMPTY)
p = (p + 1) & MASK;
return table[p] == key;
}
void erase(const int key)
{
int p = (91 * key) & MASK;
while (table[p] != key && table[p] != EMPTY)
p = (p + 1) & MASK;
if (table[p] == key)
table[p] = ERASED;
}
int main()
{
ifstream in("hashuri.in");
ofstream out("hashuri.out");
for (int i = 0; i < MAX_SIZE; ++i)
table[i] = EMPTY;
int N, X, tip;
in >> N;
while (N--)
{
in >> tip >> X;
if (tip == 1)
insert(X);
else if (tip == 2)
erase(X);
else
out << find(X) << "\n";
}
return 0;
}