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;
int Sf, Pf, Gf;
int S[100000], P[100000], G[100000];
__int128 gcd(__int128 a, __int128 b) {
  __int128 t;
  while (a > 0) t = b % a, b = a, a = t;
  return b;
}
struct frac {
  __int128 n, d;
  frac reduce() {
    __int128 g = gcd((n > 0) ? n : -n, (d > 0) ? d : -d);
    n /= g, d /= g;
    if (d < 0) n *= -1, d *= -1;
    return *this;
  }
  bool operator>(int z) { return (n > 0); }
  bool operator==(int z) { return (n == 0); }
  frac operator+(const frac o) const {
    return (frac){n * o.d + d * o.n, o.d * d};
  }
  frac operator-(const frac o) const {
    return (frac){n * o.d - d * o.n, o.d * d};
  }
  frac operator*(const frac o) const { return (frac){n * o.n, o.d * d}; }
};
struct point {
  frac x, y;
  bool operator==(const point &p) const {
    return (x.n == p.x.n) && (x.d == p.x.d) && (y.n == p.y.n) && (y.d == p.y.d);
  }
  bool operator<(const point &p) const {
    frac a = x * p.y;
    frac b = y * p.x;
    return (long double)a.n * b.d > (long double)b.n * a.d;
  }
};
point angle(int S, int P, int G) {
  frac x = (frac){Gf, Sf + Pf + Gf};
  frac y = (frac){Pf, Sf + Pf + Gf};
  frac xx = (frac){G, S + P + G};
  frac yy = (frac){P, S + P + G};
  point p = (point){xx - x, yy - y};
  p.x.reduce(), p.y.reduce();
  return p;
}
int quad(point p) {
  if ((p.x.n == 0) && (p.y.n == 0))
    return 0;
  else if ((p.x.n > 0) && (p.y.n >= 0))
    return 1;
  else if ((p.x.n <= 0) && (p.y.n > 0))
    return 2;
  else if ((p.x.n < 0) && (p.y.n <= 0))
    return 3;
  else
    return 4;
}
multiset<point> SS[5];
vector<point> vv;
int getAns() {
  if (vv.empty()) return 0;
  int i, j;
  for (i = 0; i < vv.size(); i++) {
    if ((vv[i].x.n == 0) && (vv[i].y.n == 0)) return 1;
  }
  for (i = 0; i < vv.size(); i++) {
    for (j = i + 1; j < vv.size(); j++) {
      if (vv[i].x * vv[j].y - vv[i].y * vv[j].x == 0) {
        if (vv[i].x == 0) {
          if ((vv[i].y.n <= 0) && (vv[j].y.n >= 0)) return 2;
          if ((vv[j].y.n <= 0) && (vv[i].y.n >= 0)) return 2;
        } else {
          if ((vv[i].x.n <= 0) && (vv[j].x.n >= 0)) return 2;
          if ((vv[j].x.n <= 0) && (vv[i].x.n >= 0)) return 2;
        }
      }
    }
  }
  for (i = 0; i < vv.size(); i++) {
    for (j = 0; j < vv.size(); j++) {
      if (i == j) continue;
      if (vv[i].x * vv[j].y - vv[i].y * vv[j].x > 0) break;
    }
    if (j == vv.size()) return 0;
  }
  return 3;
}
vector<int> sss;
int main() {
  int i;
  int N;
  char c;
  int b = 0, r;
  int o = 0, oo = 0;
  scanf("%d %d %d", &Sf, &Pf, &Gf);
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf(" %c", &c);
    if (c == 'A') {
      scanf("%d %d %d", &S[b], &P[b], &G[b]);
      point d = angle(S[b], P[b], G[b]);
      b++;
      int q = quad(d), oq;
      if (q == 0)
        oo++;
      else {
        if (q == 1)
          oq = 3;
        else if (q == 2)
          oq = 4;
        else if (q == 3)
          oq = 1;
        else
          oq = 2;
        if (SS[q].find(d) == SS[q].end()) {
          d.x.n *= -1, d.y.n *= -1;
          if (SS[oq].find(d) != SS[oq].end()) o++;
          d.x.n *= -1, d.y.n *= -1;
        }
        SS[q].insert(d);
      }
    } else {
      scanf("%d", &r), r--;
      point d = angle(S[r], P[r], G[r]);
      int q = quad(d), oq;
      if (q == 0)
        oo--;
      else {
        if (q == 1)
          oq = 3;
        else if (q == 2)
          oq = 4;
        else if (q == 3)
          oq = 1;
        else
          oq = 2;
        SS[q].erase(SS[q].find(d));
        if (SS[q].find(d) == SS[q].end()) {
          d.x.n *= -1, d.y.n *= -1;
          if (SS[oq].find(d) != SS[oq].end()) o--;
        }
      }
    }
    int aa = 0;
    if (oo > 0)
      aa = 1;
    else if (o > 0)
      aa = 2;
    else {
      int z = 0;
      if (SS[1].empty()) {
        if (SS[2].empty() || SS[4].empty())
          z = 1;
        else {
          point a = *SS[4].rbegin(), b = *SS[2].begin();
          if (b < a) z = 1;
        }
      }
      if (SS[2].empty()) {
        if (SS[3].empty() || SS[1].empty())
          z = 1;
        else {
          point a = *SS[1].rbegin(), b = *SS[3].begin();
          if (b < a) z = 1;
        }
      }
      if (SS[3].empty()) {
        if (SS[4].empty() || SS[2].empty())
          z = 1;
        else {
          point a = *SS[2].rbegin(), b = *SS[4].begin();
          if (b < a) z = 1;
        }
      }
      if (SS[4].empty()) {
        if (SS[1].empty() || SS[3].empty())
          z = 1;
        else {
          point a = *SS[3].rbegin(), b = *SS[1].begin();
          if (b < a) z = 1;
        }
      }
      if (z)
        aa = 0;
      else
        aa = 3;
    }
    printf("%d\n", aa);
  }
  return 0;
}