Problem: Serge, the chef of the famous restaurant "Salt, Pepper & Garlic" is trying to obtain his first Michelin star. He has been informed that a secret expert plans to visit his restaurant this evening.

Even though the expert's name hasn't been disclosed, Serge is certain he knows which dish from the menu will be ordered as well as what the taste preferences of the expert are. Namely, the expert requires an extremely precise proportion of salt, pepper and garlic powder in his dish.

Serge keeps a set of bottles with mixtures of salt, pepper and garlic powder on a special shelf in the kitchen. For each bottle, he knows the exact amount of each of the ingredients in kilograms. Serge can combine any number of bottled mixtures (or just use one of them directly) to get a mixture of particular proportions needed for a certain dish.

Luckily, the absolute amount of a mixture that needs to be added to a dish is so small that you can assume that the amounts in the bottles will always be sufficient. However, the numeric values describing the proportions may be quite large.

Serge would like to know whether it is possible to obtain the expert's favourite mixture from the available bottles, and if so—what is the smallest possible number of bottles needed to achieve that.

Furthermore, the set of bottles on the shelf may change over time as Serge receives new ones or lends his to other chefs. So he would like to answer this question after each such change.

For example, assume that expert's favorite mixture is 1:1:1 and there are three bottles of mixtures on the shelf:

$$$ \begin{array}{cccc} \hline Mixture & Salt & Pepper & Garlic powder \\\ \hline 1 & 10 & 20 & 30 \\\ 2 & 300 & 200 & 100 \\\ 3 & 12 & 15 & 27 \\\ \hline \end{array} $$$ Amount of ingredient in the bottle, kg 

To obtain the desired mixture it is enough to use an equivalent amount of mixtures from bottles 1 and 2. If bottle 2 is removed, then it is no longer possible to obtain it.

Write a program that helps Serge to solve this task!

Input

The first row contains three non-negative integers S_f, P_f and G_f (0 ≤ S_f, P_f, G_f; 0 < S_f+P_f+G_f ≤ 10^6) describing the amount of salt, pepper and garlic powder in the expert's favourite mixture. For any real α>0, (α{S_f}, α{P_f}, α{G_f}) also is an expert's favourite mixture.

In the second row, there is a positive integer N (number of changes on the shelf, N ≤ 100 000). You should assume that initially the shelf is empty.

Each of the next N rows describes a single change on the shelf: 

  * If a new bottle is added, the row contains capital letter A followed by three non-negative integers S_i, P_i and G_i (0 ≤ S_i, P_i, G_i; 0 < S_i+P_i+G_i ≤ 10^6) describing the amount of salt, pepper and garlic powder in the added bottle. Added bottles are numbered consecutively by unique integers starting from 1, that is, the i-th bottle corresponds to the i-th added bottle in the input data. 
  * If a particular bottle is removed from the shelf, the row contains capital letter R followed by the integer—the bottle number r_i. All values r_i in the removals are unique, r_i never exceeds total number of bottles added thus far. 

Output

Output N rows. The j-th row (1 ≤ j ≤ N) should contain the number x_j, the smallest number of bottles needed to prepare a mixture with the expert's favourite proportions of salt, pepper and garlic powder using the bottles available after the first j changes on the shelf, or 0 if it is not possible.

Scoring

Subtasks: 

  1. (13 points) N ≤ 50, 0 < S_i+P_i+G_i ≤ 10^2 
  2. (17 points) N ≤ 500, 0 < S_i+P_i+G_i ≤ 10^3 
  3. (30 points) N ≤ 5000, 0 < S_i+P_i+G_i ≤ 10^4 
  4. (40 points) No further constraints 

Example

Input


1 2 3
6
A 5 6 7
A 3 10 17
R 1
A 15 18 21
A 5 10 15
R 3


Output


0
2
0
2
1
1

Note

Pay attention that in the example, bottles 1 and 3 contain the same proportions of salt, pepper and garlic powder.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;
struct Point {
  long long X, Y, Z;
  Point(long long X, long long Y, long long Z) : X(X), Y(Y), Z(Z) {}
  Point() { X = Y = Z = 0; }
};
Point zr;
Point operator*(Point a, Point b) {
  return {a.Y * b.Z - a.Z * b.Y, -a.X * b.Z + a.Z * b.X, a.X * b.Y - a.Y * b.X};
}
long long operator^(Point a, Point b) {
  return a.X * b.X + a.Y * b.Y + a.Z * b.Z;
}
Point operator*(long long x, Point a) { return {a.X * x, a.Y * x, a.Z * x}; }
Point operator+(Point a, Point b) { return {a.X + b.X, a.Y + b.Y, a.Z + b.Z}; }
Point operator-(Point a, Point b) { return {a.X - b.X, a.Y - b.Y, a.Z - b.Z}; }
bool operator==(Point a, Point b) {
  return a.X == b.X && a.Y == b.Y && a.Z == b.Z;
}
bool operator!=(Point a, Point b) { return !(a == b); }
long long ffC(Point a, Point b, Point c) { return ((a * b) ^ c); }
bool inL(Point a, Point b) { return a * b == zr; }
bool one_side(Point a, Point b) {
  if (a.X != 0 && b.X != 0) return !((a.X > 0) ^ (b.X > 0));
  if (a.Y != 0 && b.Y != 0) return !((a.Y > 0) ^ (b.Y > 0));
  if (a.Z != 0 && b.Z != 0) return !((a.Z > 0) ^ (b.Z > 0));
  assert(0);
}
struct Segment {
  int val[4 * maxn], lz[4 * maxn];
  void shift(int l, int r, int id) {
    val[id] += lz[id];
    if (r - l > 1) lz[2 * id] += lz[id], lz[2 * id + 1] += lz[id];
    lz[id] = 0;
  }
  void add(int f, int s, int x, int l = 0, int r = maxn, int id = 1) {
    if (f >= s || l >= r) return;
    shift(l, r, id);
    if (s <= l || r <= f) return;
    if (f <= l && r <= s) {
      lz[id] = x;
      shift(l, r, id);
      return;
    }
    int mid = (l + r) >> 1;
    add(f, s, x, l, mid, 2 * id);
    add(f, s, x, mid, r, 2 * id + 1);
    val[id] = min(val[2 * id], val[2 * id + 1]);
  }
  int ask(int f, int s, int l = 0, int r = maxn, int id = 1) {
    if (f >= s || l >= r) return 1;
    shift(l, r, id);
    if (s <= l || r <= f) return 1;
    if (f <= l && r <= s) return val[id];
    int mid = (l + r) >> 1;
    return min(ask(f, s, l, mid, 2 * id), ask(f, s, mid, r, 2 * id + 1));
  }
};
Segment seg1, seg2;
Point p[maxn], center;
int ONE, TWO, N, fx;
int cnt[2][maxn], ID[maxn];
bool up(Point pt) {
  long long num = ffC(center, p[fx], pt);
  if (num != 0) return num > 0;
  return one_side(center * p[fx], center * pt);
}
void add(int id) {
  if (inL(center, p[id])) {
    ONE++;
    return;
  }
  bool o = up(p[id]);
  if (++cnt[o][ID[id]] == 1 && cnt[!o][ID[id]]) {
    TWO++;
  }
  if (o) {
    seg1.add(ID[id] + 1, N, 1);
    seg2.add(0, ID[id], 1);
  } else {
    seg1.add(0, ID[id], 1);
    seg2.add(ID[id] + 1, N, 1);
  }
}
void era(int id) {
  if (inL(center, p[id])) {
    ONE--;
    return;
  }
  bool o = up(p[id]);
  if (--cnt[o][ID[id]] == 0 && cnt[!o][ID[id]]) {
    TWO--;
  }
  if (o) {
    seg1.add(ID[id] + 1, N, -1);
    seg2.add(0, ID[id], -1);
  } else {
    seg1.add(0, ID[id], -1);
    seg2.add(ID[id] + 1, N, -1);
  }
}
int solve() {
  if (ONE) return 1;
  if (TWO) return 2;
  if (N == 0 || seg1.ask(0, N) == 0 || seg2.ask(0, N) == 0) return 0;
  return 3;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie();
  cin >> center.X >> center.Y >> center.Z;
  int q, C = 0;
  vector<pair<Point, int> > vec;
  vector<int> tdo;
  cin >> q;
  while (q--) {
    char ch;
    cin >> ch;
    if (ch == 'A') {
      cin >> p[C].X >> p[C].Y >> p[C].Z;
      tdo.push_back(2 * C + 1);
      C++;
    } else {
      int id;
      cin >> id;
      --id;
      tdo.push_back(2 * id);
    }
  }
  fx = -1;
  for (int i = 0; i < C; i++) {
    if (inL(center, p[i])) continue;
    fx = i;
  }
  for (int i = 0; i < C; i++) {
    if (inL(center, p[i])) continue;
    if (up(p[i]))
      vec.push_back({p[i], i});
    else
      vec.push_back({2 * center - p[i], i});
  }
  sort(vec.begin(), vec.end(), [](pair<Point, int> a, pair<Point, int> b) {
    return ffC(center, a.first, b.first) > 0;
  });
  Point lst;
  for (auto p : vec) {
    if (N == 0 || ffC(center, lst, p.first) != 0) {
      N++;
      lst = p.first;
    }
    ID[p.second] = N - 1;
  }
  for (int x : tdo) {
    if (x & 1)
      add(x >> 1);
    else
      era(x >> 1);
    cout << solve() << "\n";
  }
  return 0;
}