#include <cstdio>
#include <iostream>
#include <map>
using namespace std;
map<long long int, long long int> m;
map<long long int, long long int> f;
int main() {
long long int n;
scanf("%lld", &n);
while (n--) {
long long int a, b;
scanf("%lld %lld", &a, &b);
switch (a) {
case 1:
if (f[m[b]] > 0) {
f[m[b]]--;
}
m[b]++;
f[m[b]]++;
break;
case 2:
if (f[m[b]] > 0) {
f[m[b]]--;
}
if (m[b] > 0) {
m[b]--;
}
f[m[b]]++;
break;
case 3:
printf("%d\n", f.count(b) && f[b] > 0);
break;
}
}
return 0;
}
System Design for Beginners
A masterclass that helps early engineers and product managers become great at designing scalable systems.
180+ learners
Details →System Design Masterclass
A masterclass that helps you become great at designing scalable, fault-tolerant, and highly available systems.
1000+ learners
Details →Redis Internals
Learn internals of Redis by re-implementing some of the core features in Golang.
98+ learners
Details →