#include <bits/stdc++.h>
using namespace std;
template <typename T>
T read1() {
  T t = 0;
  char k;
  bool vis = 0;
  do (k = getchar()) == '-' && (vis = 1);
  while ('0' > k || k > '9');
  while ('0' <= k && k <= '9')
    t = (t << 3) + (t << 1) + (k ^ '0'), k = getchar();
  return vis ? -t : t;
}
long long Abs(long long x) { return x < 0 ? -x : x; }
char str[3];
int t;
long long tot;
const long long V = 1ll << 31;
const double Pi = acos(-1);
map<pair<long long, long long>, int> ma;
pair<long long, long long> A[100005];
bool judge(long long x, long long y, long long z, long long w) {
  if ((x == 0 || y == 0) && (z == 0 || w == 0)) return 0;
  if (x == 0 || y == 0) return (z < 0) ^ (w < 0);
  if (z == 0 || w == 0) return (x < 0) == (y < 0);
  if ((x > 0) * (y > 0) != (z > 0) * (w > 0))
    return (x > 0) * (y > 0) > (z > 0) * (w > 0);
  long long l1 =
                (x / V) * (y / V) + ((x % V) * (y / V) + (x / V) * (y % V)) / V,
            l2 = ((x % V) * (y / V) + (x / V) * (y % V)) % V +
                 (x % V) * (y % V) / V,
            l3 = (x % V) * (y % V) % V;
  long long r1 =
                (z / V) * (w / V) + ((z % V) * (w / V) + (z / V) * (w % V)) / V,
            r2 = ((z % V) * (w / V) + (z / V) * (w % V)) % V +
                 (z % V) * (w % V) / V,
            r3 = (z % V) * (w % V) % V;
  if (l3 >= V) l2 += l3 / V, l3 %= V;
  if (l2 >= V) l1 += l2 / V, l2 %= V;
  if (r3 >= V) r2 += r3 / V, r3 %= V;
  if (r2 >= V) r1 += r2 / V, r2 %= V;
  return l1 == r1 ? l2 == r2 ? l3 > r3 : l2 > r2 : l1 > r1;
}
const int E[3][3] = {{6, 7, 8}, {5, 9, 1}, {4, 3, 2}};
struct X {
  long long x, y;
  X(long long _x = 0, long long _y = 0) {
    x = _x;
    y = _y;
  }
  X(pair<long long, long long> z) : x(z.first), y(z.second) {}
  int Wh() const { return E[(y > 0) + (y >= 0)][(x > 0) + (x >= 0)]; }
  X operator-() const { return X(-x, -y); }
  bool operator<(const X &w) const { return judge(x, w.y, y, w.x); }
  bool operator>(const X &w) const { return w < *this; }
  bool operator<=(const X &w) const { return !(*this > w); }
  bool operator>=(const X &w) const { return w <= *this; }
  bool operator==(const X &w) const { return !(*this < w || *this > w); }
};
multiset<X> se[2];
X va[100005];
long long Gcd(long long x, long long y) {
  if (y < 0 || x < 0) return Gcd(Abs(x), Abs(y));
  if (!x) return y;
  while (y) swap(y, x %= y);
  return x;
}
bool judge() {
  if (se[0].size() > 1) {
    auto l = se[0].begin(), r = se[0].end(), x = se[1].lower_bound(-*l);
    --r;
    if (x != se[1].end() && *x <= -*r) return 1;
  }
  if (se[1].size() > 1) {
    auto l = se[1].begin(), r = se[1].end(), x = se[0].lower_bound(-*l);
    --r;
    if (x != se[0].end() && *x <= -*r) return 1;
  }
  return 0;
}
int main() {
  long long a = read1<long long>(), b = read1<long long>(),
            c = read1<long long>();
  int w = 0;
  if (a == 0) swap(a, b), w |= 1;
  if (a == 0) swap(a, c), w |= 2;
  int cnt = 0;
  for (int T = read1<long long>(); T--;) {
    scanf("%s", str);
    if (*str == 'A') {
      long long x = read1<long long>(), y = read1<long long>(),
                z = read1<long long>();
      if (w & 1) swap(x, y);
      if (w & 2) swap(x, z);
      if (b == 0 && y != 0) {
        A[++cnt] = make_pair(2, 4);
        goto OP;
      }
      if (c == 0 && z != 0) {
        A[++cnt] = make_pair(2, 4);
        goto OP;
      }
      y = b * x - a * y;
      z = c * x - a * z;
      if (c) y *= c;
      if (b) z *= b;
      x = Gcd(y, z);
      if (x) y /= x, z /= x;
      tot += ma[make_pair(-y, -z)];
      if (!ma[A[++cnt] = make_pair(y, z)]++) ++t;
      va[cnt] = X(y, z);
      if (y || z)
        if (va[cnt].Wh() <= 4)
          se[0].insert(va[cnt]);
        else
          se[1].insert(va[cnt]);
    } else {
      int v = read1<long long>();
      if (A[v].first == 2 && A[v].second == 4) goto OP;
      if (!--ma[A[v]]) --t;
      tot -= ma[make_pair(-A[v].first, -A[v].second)];
      if (va[v].x || va[v].y)
        if (va[v].Wh() <= 4)
          se[0].erase(se[0].lower_bound(va[v]));
        else
          se[1].erase(se[1].lower_bound(va[v]));
    }
  OP:;
    if (ma[make_pair(0, 0)])
      puts("1");
    else if (tot)
      puts("2");
    else if (t > 2 && judge())
      puts("3");
    else
      puts("0");
  }
  return 0;
}
