#include <bits/stdc++.h>
using namespace std;
struct pt {
  long long x, y, z;
  friend long long sp(const pt& a, const pt& b) {
    return a.x * b.x + a.y * b.y + a.z * b.z;
  }
  friend pt cp(const pt& a, const pt& b) {
    return {a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z,
            a.x * b.y - a.y * b.x};
  }
  friend bool colinear(const pt& a, const pt& b) {
    return a.y * b.z == a.z * b.y && a.z * b.x == a.x * b.z &&
           a.x * b.y == a.y * b.x;
  }
  friend pt operator-(const pt& a) { return {-a.x, -a.y, -a.z}; }
};
pt read_point() {
  long long x, y, z;
  scanf("%lld%lld%lld ", &x, &y, &z);
  return {x, y, z};
}
pt origin;
pt plane1, plane2;
int side(pt p) {
  return make_pair(sp(plane1, p), sp(plane2, p)) >
         make_pair<long long, long long>(0, 0);
}
vector<pt> points;
struct angle_cmp {
  bool operator()(const pt& a, const pt& b) const {
    return sp(cp(a, b), origin) > 0;
  }
};
multiset<pt, angle_cmp> points2[2];
vector<multiset<pt, angle_cmp>::iterator> points2_it;
int main() {
  origin = read_point();
  if (origin.x != 0) {
    plane1 = {origin.y, -origin.x, 0};
    plane2 = {origin.z, 0, -origin.x};
  } else if (origin.y != 0) {
    plane1 = {-origin.y, origin.x, 0};
    plane2 = {0, origin.z, -origin.y};
  } else if (origin.z != 0) {
    plane1 = {-origin.z, 0, origin.x};
    plane2 = {0, -origin.z, origin.y};
  } else {
    assert(false);
  }
  int N;
  scanf("%d ", &N);
  int nr1 = 0, nr2 = 0;
  bool nr3 = false;
  for (int n = (0); n < (N); n++) {
    char typ;
    scanf("%c ", &typ);
    if (typ == 'A') {
      pt p = read_point();
      points.push_back(p);
      if (colinear(p, origin)) {
        nr1++;
        points2_it.emplace_back();
      } else {
        int s = side(p);
        points2_it.push_back(points2[s].insert(p));
        nr2 += points2[1 - s].count(-p);
        auto it = points2_it.back();
        if (points2[s].count(p) == 1) {
          if (points2[1 - s].empty()) {
            nr3 = false;
          } else {
            pt p1, p2;
            if (it == points2[s].begin()) {
              p1 = *points2[1 - s].rbegin();
            } else {
              auto h = it;
              h--;
              p1 = *h;
            }
            auto h = it;
            h++;
            if (h == points2[s].end()) {
              p2 = *points2[1 - s].begin();
            } else {
              p2 = *h;
            }
            if (angle_cmp()(p2, p1) && angle_cmp()(p1, p) &&
                angle_cmp()(p, p2)) {
              nr3 = true;
            }
          }
        }
      }
    } else if (typ == 'R') {
      int i;
      scanf("%d ", &i);
      i--;
      pt p = points[i];
      if (colinear(p, origin)) {
        nr1--;
      } else {
        int s = side(p);
        nr2 -= points2[1 - s].count(-p);
        auto it = points2_it[i];
        if (points2[s].count(p) == 1) {
          if (points2[s].size() == 1 || points2[1 - s].empty()) {
            nr3 = false;
          } else {
            pt p1, p2;
            if (it == points2[s].begin()) {
              p1 = *points2[1 - s].rbegin();
            } else {
              auto h = it;
              h--;
              p1 = *h;
            }
            auto h = it;
            h++;
            if (h == points2[s].end()) {
              p2 = *points2[1 - s].begin();
            } else {
              p2 = *h;
            }
            if (angle_cmp()(p2, p1)) {
              nr3 = false;
            }
          }
        }
        points2[s].erase(points2_it[i]);
      }
    } else {
      assert(false);
    }
    if (nr2 > 0) nr3 = true;
    if (nr1 > 0) {
      printf("1\n");
    } else if (nr2 > 0) {
      printf("2\n");
    } else if (nr3) {
      printf("3\n");
    } else {
      printf("0\n");
    }
  }
  return 0;
}
