#include<bits/stdc++.h>
#define fr first
#define sc second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
//#define int long long
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
const int inf = 1e9+7;
const int mod = 998244353;
const ll linf = LLONG_MAX;
int N, NR;
unordered_map <int, int> M;
int main()
{
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
int i, tip, x;
scanf("%d ", &N);
for (i = 1; i <= N; i++)
{
scanf("%d %d ", &tip, &x);
if (tip == 1 && M.find(x)==M.end()) M[x] = ++NR;
if (tip == 2) M.erase(x);
if (tip == 3) printf("%d\n", M.find(x) != M.end());
}
return 0;
}