#include <fstream>
#include <vector>
#define MOD 666013
///1017932
using namespace std;
///1017932
ifstream cin ("hashuri.in");
ofstream cout ("hashuri.out");
///1017932
vector<int> myhash[MOD];
///1017932
void add(int x) {
int nr, i, n;
nr = x % MOD;
///1017932
i = 0;
n = myhash[nr].size();
while (i < n && myhash[nr][i] != x)
i++;
if (i == n)
myhash[nr].push_back(x);
}
///1017932
bool search(int x) {
int nr, i, n;
///1017932
i = 0;
nr = x % MOD;
n = myhash[nr].size();
while (i < n && myhash[nr][i] != x)
i++;
if (i == n)
return 0;
return 1;
}
///1017932
void del(int x) {
int nr, i, n;
///1017932
i = 0;
nr = x % MOD;
n = myhash[nr].size();
while (i < n && myhash[nr][i] != x)
i++;
if (i < n)
myhash[nr].erase(myhash[nr].begin() + i);
}
///1017932
int main() {
int n, x, op;
cin >> n;
///1017932
while (n--) {
cin >> op >> x;
if (op == 1)
add(x);
else if (op == 2)
del(x);
else
cout << search(x) << "\n";
}
return 0;
}