#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
const int hash_mod = 666013;
vector<int> hash_table[hash_mod];
int get_key(int x) { return (x % hash_mod); }
void add(int x) { hash_table[get_key(x)].push_back(x); }
void del(int x) {
auto key = get_key(x);
auto it = find(hash_table[key].begin(), hash_table[key].end(), x);
if (it != hash_table[key].end())
hash_table[key].erase(it);
}
int search(int x) {
auto key = get_key(x);
auto it = find(hash_table[key].begin(), hash_table[key].end(), x);
return (it != hash_table[key].end());
}
void solve() {
int n, op, x;
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d %d", &op, &x);
if (op == 1)
add(x);
else if (op == 2)
del(x);
else
printf("%d\n", search(x));
}
}
int main() {
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
solve();
return 0;
}