#include <fstream>
using namespace std;
const int N = 1e6 + 1;
const int MOD = 666019;
int val[N], urm[N], lst[MOD], nr = 0;
void adauga(int x) {
int c = x % MOD;
val[++nr] = x;
urm[nr] = lst[c];
lst[c] = nr;
}
bool cauta(int x) {
int c = x % MOD, p = lst[c];
while (p != 0) {
if (val[p] == x)
return true;
p = urm[p];
}
return false;
}
void sterge(int x) {
int c = x % MOD, p = lst[c];
while (p != 0 && val[p] != x)
p = urm[p];
if (!p)
return;
swap(val[p], val[lst[c]]);
lst[c] = urm[lst[c]];
}
int main() {
ifstream in("hashuri.in");
ofstream out("hashuri.out");
int n, op, x;
in >> n;
while (n--) {
in >> op >> x;
if (op == 1)
adauga(x);
else if (op == 2)
sterge(x);
else
out << cauta(x) << '\n';
}
in.close();
out.close();
}