#include <bits/stdc++.h>
using namespace std;
#define N 1000005
#define M 666019
int val[N], urm[N], lst[M], nr;
bool exist(int x) {
for(int p = lst[x%M]; p; p = urm[p])
if(val[p] == x) return true;
return false;
}
void add(int x) {
if(exist(x)) return;
val[++nr] = x;
urm[nr] = lst[x%M];
lst[x%M] = nr;
}
void remove(int x) {
int p = lst[x%M];
if(x == val[p])
lst[x%M] = urm[p];
else while(urm[p]) {
if(x == val[urm[p]]) {
urm[p] = urm[urm[p]];
break;
}
p = urm[p];
}
}
int main() {
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n, k, x;
fin >> n; do {
fin >> k >> x;
if(k == 1) add(x);
else if(k == 2) remove(x);
else (fout << exist(x)).put('\n');
} while(--n);
}