#include <fstream>
#include <unordered_map>
#define mod 666013
using namespace std;
unsigned int hashFunction(unsigned int x) {
x = ((x >> 16) ^ x) * 0x45d9f3b;
x = ((x >> 16) ^ x) * 0x45d9f3b;
x = ((x >> 16) ^ x);
return x;
}
int main()
{
int N;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
unordered_map<int, int> hash;
in>>N;
for (int i = 0; i < N; ++i) {
int c, x;
in>>c>>x;
switch(c) {
case 1: hash.insert(make_pair(hashFunction(x), x)); break;
case 2: hash.erase(hashFunction(x)); break;
case 3: out<<(hash.find(hashFunction(x)) != hash.end())<<"\n"; break;
default: return -1;
}
}
in.close();
out.close();
return 0;
}