import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
Scan cin = new Scan("hashuri.in");
PrintWriter cout = new PrintWriter("hashuri.out");
HashMap<Integer, Integer> H = new HashMap<Integer, Integer>();
int t, x, n = cin.nextInt();
while (n-- != 0) {
t = cin.nextInt();
x = cin.nextInt();
if (t == 1) {
if (!H.containsKey(x))
H.put(x, 1);
} else if (t == 2)
H.remove(x);
else {
if (H.containsKey(x)) cout.print("1\n");
else cout.print("0\n");
}
}
cout.close();
}
static class Scan {
static BufferedReader br;
static StringTokenizer st;
Scan(String file) throws IOException {
br = new BufferedReader(new FileReader(file));
}
String next() throws IOException {
while (st == null || !st.hasMoreElements())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
int nextInt() throws IOException {
return Integer.parseInt(next());
}
}
}