#include <bits/stdc++.h>
using namespace std;
const long long inf = 1ll << 30;
const long long INF = inf * inf;
inline bool i128c(const long long& a, const long long& b, const long long& c,
                  const long long& d) {
  if (b >= 0 && d <= 0) return 0;
  if (b < 0 && d > 0) return 1;
  if (b == 0) return d > 0;
  if (d == 0) return b < 0;
  if (b < 0) return i128c(c, -d, a, -b);
  long long v11 = (a / inf) * (b / inf);
  long long v12 = (a / inf) * (b % inf) + (a % inf) * (b / inf);
  long long v13 = (a % inf) * (b % inf);
  v12 += v13 / inf;
  v13 %= inf;
  v11 += v12 / inf;
  v12 %= inf;
  long long v21 = (c / inf) * (d / inf);
  long long v22 = (c / inf) * (d % inf) + (c % inf) * (d / inf);
  long long v23 = (c % inf) * (d % inf);
  v22 += v23 / inf;
  v23 %= inf;
  v21 += v22 / inf;
  v22 %= inf;
  return v11 == v21 ? (v12 == v22 ? v13 < v23 : v12 < v22) : v11 < v21;
}
int zp, zm, zc;
inline bool cmpf(const pair<long long, long long>& x,
                 const pair<long long, long long>& y) {
  return i128c(x.second, y.first, y.second, x.first);
}
struct cmp {
  inline bool operator()(const pair<long long, long long>& x,
                         const pair<long long, long long>& y) const {
    return i128c(x.second, y.first, y.second, x.first);
  }
};
inline long long mygcd(long long x, long long y) {
  while (y != 0) x %= y, swap(x, y);
  return x;
}
map<pair<long long, long long>, int, cmp> pc, mc;
long long cmt;
pair<long long, long long> bot[100010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long aa, bb, cc;
  cin >> aa >> bb >> cc;
  int flag = 0;
  if (aa == 0) {
    if (bb != 0)
      flag = 1, swap(aa, bb);
    else
      flag = 2, swap(aa, cc);
  }
  int tc;
  cin >> tc;
  int bct = 0;
  for (int ti = 0; ti < tc; ti++) {
    char tp;
    cin >> tp;
    if (tp == 'A') {
      int id = ++bct;
      long long a, b, c;
      cin >> a >> b >> c;
      if (flag == 1)
        swap(a, b);
      else if (flag == 2)
        swap(a, c);
      long long x = b * aa - bb * a;
      long long y = c * aa - cc * a;
      if (x != 0 || y != 0) {
        long long g = abs(mygcd(x, y));
        x /= g;
        y /= g;
      }
      bot[id] = pair<long long, long long>(x, y);
      if (x == 0) {
        if (y == 0)
          zc++;
        else
          (y == 1 ? zp : zm)++;
      } else if (x > 0) {
        cmt += mc[pair<long long, long long>(x, y)];
        pc[pair<long long, long long>(x, y)]++;
      } else {
        cmt += pc[pair<long long, long long>(-x, -y)];
        mc[pair<long long, long long>(-x, -y)]++;
      }
    } else {
      int id;
      cin >> id;
      long long x = bot[id].first;
      long long y = bot[id].second;
      if (x == 0) {
        if (y == 0)
          zc--;
        else
          (y == 1 ? zp : zm)--;
      } else if (x > 0) {
        pc[pair<long long, long long>(x, y)]--;
        cmt -= mc[pair<long long, long long>(x, y)];
      } else {
        mc[pair<long long, long long>(-x, -y)]--;
        cmt -= pc[pair<long long, long long>(-x, -y)];
      }
    }
    while (!pc.empty() && pc.begin()->second == 0) pc.erase(pc.begin());
    while (!pc.empty() && pc.rbegin()->second == 0) pc.erase(--pc.end());
    while (!mc.empty() && mc.begin()->second == 0) mc.erase(mc.begin());
    while (!mc.empty() && mc.rbegin()->second == 0) mc.erase(--mc.end());
    if (zc > 0)
      cout << "1\n";
    else if ((zp > 0 && zm > 0) || cmt > 0)
      cout << "2\n";
    else if (pc.empty() || mc.empty())
      cout << "0\n";
    else {
      bool f1 = cmpf(pc.begin()->first, mc.rbegin()->first) || zm > 0;
      bool f2 = cmpf(mc.begin()->first, pc.rbegin()->first) || zp > 0;
      if (f1 && f2)
        cout << "3\n";
      else
        cout << "0\n";
    }
  }
  cout.flush();
  return 0;
}
