#include <fstream>
#include <vector>
#include <unordered_set>
using namespace std;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
const int MOD = 1000133;
unordered_set<int> h[1001000];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int tip, nr;
cin >> tip >> nr;
int pos = nr % MOD;
if (tip == 1) {
h[pos].insert(nr);
} else if (tip == 2) {
h[pos].erase(nr);
} else if (tip == 3) {
cout << (h[pos].count(nr) ? "1\n" : "0\n");
}
}
return 0;
}