#include <bits/stdc++.h>
using namespace std;
bool cross(complex<long long> a, complex<long long> b) {
  return __int128(a.real()) * b.imag() < __int128(a.imag()) * b.real();
}
long long gcd(long long a, long long b) {
  a = abs(a), b = abs(b);
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}
pair<complex<long long>, long long> get_point() {
  int s, p, g;
  cin >> s >> p >> g;
  return {{s, p}, s + p + g};
}
void reduce(complex<long long> &p) {
  long long d = gcd(p.real(), p.imag());
  if (d != 0) p /= d;
}
pair<long long, long long> to_pair(complex<long long> a) {
  return {a.real(), a.imag()};
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  pair<complex<long long>, long long> ori = get_point();
  int n;
  cin >> n;
  auto p_comp = [](complex<long long> a, complex<long long> b) {
    bool as = to_pair(a) < make_pair(0ll, 0ll);
    bool bs = to_pair(b) < make_pair(0ll, 0ll);
    if (as != bs) return as < bs;
    return cross(a, b);
  };
  map<complex<long long>, int, decltype(p_comp)> ms(p_comp);
  set<complex<long long>, decltype(p_comp)> ss(p_comp);
  vector<complex<long long> > ps;
  int ones = 0, twos = 0, ntr = 0;
  auto ntr_calc = [&](complex<long long> a, bool strict) {
    if (int(ss.size()) < 2) return false;
    auto jt = strict ? ss.upper_bound(a) : ss.lower_bound(a);
    if (jt == ss.end()) jt = ss.begin();
    auto it = prev(jt == ss.begin() ? ss.end() : jt);
    return cross(*jt, *it);
  };
  auto upd = [&](complex<long long> a, int dif) {
    if (a == complex<long long>(0, 0)) {
      ones += dif;
    } else {
      int pr = ms[a], nx = pr + dif;
      ms[a] = nx;
      if (pr == 0) {
        if (ss.count(-a)) twos++;
        ntr -= ntr_calc(a, false);
        ss.insert(a);
        ntr += ntr_calc(a, true);
        ntr += ntr_calc(a, false);
      } else if (nx == 0) {
        if (ss.count(-a)) twos--;
        ntr -= ntr_calc(a, true);
        ntr -= ntr_calc(a, false);
        ss.erase(a);
        ntr += ntr_calc(a, false);
      }
    }
  };
  for (int _ = (0); _ < (n); ++_) {
    char c;
    cin >> c;
    if (c == 'A') {
      pair<complex<long long>, long long> q = get_point();
      complex<long long> p(q.first * ori.second - ori.first * q.second);
      reduce(p);
      ps.push_back(p);
      upd(p, 1);
    } else {
      int r;
      cin >> r;
      upd(ps[r - 1], -1);
    }
    int ans = 0;
    if (!ntr && int(ss.size()) > 2) ans = 3;
    if (twos) ans = 2;
    if (ones) ans = 1;
    cout << ans << endl;
  }
}
