#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define inline inline __attribute__((always_inline))
using namespace std;
struct Point {
long long x, y;
inline Point operator-() const {
return {-x, -y};
}
};
inline bool cw(const Point &p, const Point &q) {
return (__int128) p.x * q.y < (__int128) p.y * q.x;
}
inline bool ccw(const Point &p, const Point &q) {
return (__int128) p.x * q.y > (__int128) p.y * q.x;
}
struct Compare {
inline bool operator()(const Point &p, const Point &q) const {
bool phalf = p.y ? p.y > 0 : p.x > 0;
bool qhalf = q.y ? q.y > 0 : q.x > 0;
return phalf != qhalf ? phalf > qhalf : ccw(p, q);
}
};
signed main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// freopen("input.txt", "r", stdin);
int x0, y0, z0;
cin >> x0 >> y0 >> z0;
int q;
cin >> q;
int can1 = 0;
long long can2 = 0;
bool can3 = false;
map<Point, int, Compare> cnt;
auto prev = [&cnt](map<Point, int, Compare>::iterator it) {
return it == cnt.begin() ? --cnt.end() : --it;
};
auto next = [&cnt](map<Point, int, Compare>::iterator it) {
return ++it == cnt.end() ? cnt.begin() : it;
};
vector<Point> points;
points.reserve(q);
while (q--) {
char type;
cin >> type;
if (type == 'A') {
int x, y, z;
cin >> x >> y >> z;
Point p{(long long) x * (x0 + y0 + z0) - (x + y + z) * (long long) x0,
(long long) y * (x0 + y0 + z0) - (x + y + z) * (long long) y0};
long long d = max(__gcd(p.x, p.y), 1ll);
p.x /= d;
p.y /= d;
points.push_back(p);
if (p.x == 0 && p.y == 0) {
can1++;
goto reply;
}
auto [it, inserted] = cnt.try_emplace(p, 0);
it->second++;
if (inserted && cnt.size() > 1) {
auto low = prev(it);
auto high = next(it);
if (cw(low->first, high->first) && !cw(low->first, p) && !cw(p, high->first)) {
can3 = true;
}
}
it = cnt.find(-p);
if (it != cnt.end()) can2 += it->second;
} else {
int i;
cin >> i;
const Point &p = points[i - 1];
if (p.x == 0 && p.y == 0) {
can1--;
goto reply;
}
auto it = cnt.find(p);
if (--(it->second) == 0) {
auto high = cnt.erase(it);
if (cnt.size() > 1) {
auto low = prev(high);
if (cw(low->first, high->first) && !cw(low->first, p) && !cw(p, high->first)) {
can3 = false;
}
} else can3 = false;
}
it = cnt.find(-p);
if (it != cnt.end()) can2 -= it->second;
}
reply:
cout << (can1 ? "1\n" : can2 ? "2\n" : can3 ? "3\n" : "0\n");
}
return 0;
}