#include <bits/stdc++.h>
using namespace std;
const int N = 100025;
struct point {
  int64_t x, y;
  point() {}
  point(int64_t x, int64_t y) : x(x), y(y) {}
  friend point inv(const point &p) { return point(-p.x, -p.y); }
  friend __int128 cross(const point &a, const point &b) {
    return __int128(a.x) * b.y - __int128(a.y) * b.x;
  }
  friend bool operator<(const point &a, const point &b) {
    int da = (a.y == 0 ? (a.x > 0 ? 0 : 2) : (a.y > 0 ? 1 : 3));
    int db = (b.y == 0 ? (b.x > 0 ? 0 : 2) : (b.y > 0 ? 1 : 3));
    __int128 C = cross(a, b);
    return da != db ? da < db : C > 0;
  }
} pts[N];
map<point, int> mp;
int tot;
int zero;
int64_t cnt;
bool rm[N];
int64_t S, P, G;
int q;
int invalid;
void add(point p) {
  if (p.x == 0 && p.y == 0) return ++zero, void();
  if (mp.count(inv(p))) cnt += mp[inv(p)];
  ((void)0);
  if (mp.size() && !mp.count(p)) {
    auto nxt = mp.lower_bound(p);
    if (nxt == mp.end()) nxt = mp.begin();
    auto prv = nxt == mp.begin() ? prev(mp.end()) : prev(nxt);
    __int128 A = cross(prv->first, p);
    __int128 B = cross(p, nxt->first);
    __int128 C = cross(prv->first, nxt->first);
    if (A < 0) ++invalid;
    if (B < 0) ++invalid;
    if (C < 0) --invalid;
  }
  ++mp[p];
}
void del(point p) {
  if (p.x == 0 && p.y == 0) return --zero, void();
  if (mp.count(inv(p))) cnt -= mp[inv(p)];
  if (--mp[p] == 0) mp.erase(p);
  if (mp.size() && !mp.count(p)) {
    auto nxt = mp.lower_bound(p);
    if (nxt == mp.end()) nxt = mp.begin();
    auto prv = nxt == mp.begin() ? prev(mp.end()) : prev(nxt);
    __int128 A = cross(prv->first, p);
    __int128 B = cross(p, nxt->first);
    __int128 C = cross(prv->first, nxt->first);
    if (A < 0) --invalid;
    if (B < 0) --invalid;
    if (C < 0) ++invalid;
  }
}
bool ok() { return mp.size() >= 3 && invalid == 0; }
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> S >> P >> G >> q;
  while (q--) {
    char c;
    cin >> c;
    if (c == 'A') {
      int x, y, z;
      cin >> x >> y >> z;
      int64_t L = S * S + P * P + G * G, I = S * x + P * y + G * z;
      int64_t X = x * L - S * I, Y = y * L - P * I, Z = z * L - G * I;
      if (S)
        pts[tot++] = point(Y, Z);
      else if (P)
        pts[tot++] = point(X, Z);
      else
        pts[tot++] = point(X, Y);
      add(pts[tot - 1]);
      ((void)0);
    } else {
      int id;
      cin >> id;
      del(pts[id - 1]);
      rm[id - 1] = true;
    }
    if (zero)
      cout << 1 << '\n';
    else if (cnt)
      cout << 2 << '\n';
    else if (ok())
      cout << 3 << '\n';
    else
      cout << 0 << '\n';
  }
}
