#include <bits/stdc++.h>
using namespace std;
const int eps = 1e5;
const long double pi = acos(-1);
const int N = 1e5 + 7;
vector<pair<long long, long long>> who[4 * N];
vector<long double> an[4 * N];
void add(int ql, int qr, long long f, long long s, long double ang, int l,
         int r, int v) {
  if (r < ql || qr < l) return;
  if (ql <= l && r <= qr) {
    who[v].push_back({f, s});
    an[v].push_back(ang);
  } else {
    int m = (l + r) >> 1;
    add(ql, qr, f, s, ang, l, m, 2 * v + 1);
    add(ql, qr, f, s, ang, m + 1, r, 2 * v + 2);
  }
}
int ans[N];
multiset<long long> have;
int cur_ans = 4;
int cnt = 0;
const long long M = 1e15;
void rec(int l, int r, int v) {
  int last_ans = cur_ans;
  for (int i = 0; i < (int)who[v].size(); ++i) {
    auto p = who[v][i];
    long long a = an[v][i] * M;
    if (p.first == 0 && p.second == 0) {
      ++cnt;
    } else {
      have.insert(a);
      long long b = *prev(have.upper_bound(a + (long long)(pi * M) + eps));
      if (abs(b - (a + pi * M)) < eps) cur_ans = min(cur_ans, 2);
      long long c;
      if (abs(b - a) < eps) {
        c = a;
      } else {
        c = *prev(have.upper_bound(b + pi * M));
      }
      long double d = *have.lower_bound(a - pi * M - eps);
      if (abs(d - (a - pi * M)) < eps) cur_ans = min(cur_ans, 2);
      long double e;
      if (abs(d - a) < eps) {
        e = a;
      } else {
        e = *have.lower_bound(d - pi * M);
      }
      if (cur_ans > 3 && cnt == 0) {
        if (a - c + 2 * pi * M < pi * M) {
          cur_ans = 3;
        }
      }
      if (cur_ans > 3 && cnt == 0) {
        if (e - a + 2 * pi * M < pi * M) {
          cur_ans = 3;
        }
      }
      if (cur_ans > 3 && cnt == 0) {
        if (d - b + 2 * pi * M < pi * M) {
          cur_ans = 3;
        }
      }
    }
  }
  if (l == r) {
    if (cnt > 0)
      ans[l] = 1;
    else if (cur_ans != 4)
      ans[l] = cur_ans;
    else
      ans[l] = 0;
  } else {
    int m = (l + r) >> 1;
    rec(l, m, 2 * v + 1);
    rec(m + 1, r, 2 * v + 2);
  }
  cur_ans = last_ans;
  for (int i = 0; i < (int)who[v].size(); ++i) {
    auto p = who[v][i];
    if (p.first == 0 && p.second == 0)
      --cnt;
    else {
      have.erase(have.find(an[v][i] * M));
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int aa, bb, cc;
  cin >> aa >> bb >> cc;
  int id = -1;
  if (aa != 0) {
    id = 0;
  } else if (bb != 0) {
    id = 1;
  } else {
    id = 2;
  }
  if (id == 1) {
    swap(aa, bb);
  }
  if (id == 2) {
    swap(aa, cc);
  }
  int n;
  cin >> n;
  vector<long long> f, s;
  vector<int> st;
  vector<int> en;
  for (int i = 0; i < n; ++i) {
    char c;
    cin >> c;
    if (c == 'A') {
      int a, b, c;
      cin >> a >> b >> c;
      if (id == 1) swap(a, b);
      if (id == 2) swap(a, c);
      f.push_back((long long)b * aa - (long long)bb * a);
      s.push_back((long long)cc * a - (long long)c * aa);
      st.push_back(i);
      en.push_back(n - 1);
    } else {
      int p;
      cin >> p;
      --p;
      en[p] = i - 1;
    }
  }
  for (int i = 0; i < (int)f.size(); ++i) {
    long double ang = 0;
    if (f[i] != 0 || s[i] != 0) ang = atan2((long double)f[i], s[i]);
    add(st[i], en[i], f[i], s[i], ang, 0, n - 1, 0);
  }
  rec(0, n - 1, 0);
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << '\n';
  }
}
