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>
unsigned int Z = 12345, X = 12345;
int rand_() { return (Z *= 3) >> 1; }
long long abs_(long long x) { return x > 0 ? x : -x; }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long *ox[200000], *oy[200000];
int *oc[200000], oo[200000];
int hash(long long x, long long y) {
  return ((x % 0x7fffffff * X % 0x7fffffff + y) % 0x7fffffff + 0x7fffffff) %
         200000;
}
void ht_add(long long x, long long y, int c) {
  int h = hash(x, y), o;
  for (o = 0; o < oo[h]; o++)
    if (ox[h][o] == x && oy[h][o] == y) {
      oc[h][o] += c;
      return;
    }
  o = oo[h]++;
  if (o >= 2 && (o & o - 1) == 0) {
    ox[h] = (long long *)realloc(ox[h], o * 2 * sizeof *ox[h]);
    oy[h] = (long long *)realloc(oy[h], o * 2 * sizeof *oy[h]);
    oc[h] = (int *)realloc(oc[h], o * 2 * sizeof *oc[h]);
  }
  ox[h][o] = x, oy[h][o] = y, oc[h][o] = c;
}
int ht_get(long long x, long long y) {
  int h = hash(x, y), o;
  for (o = 0; o < oo[h]; o++)
    if (ox[h][o] == x && oy[h][o] == y) return oc[h][o];
  return 0;
}
long long xx[100000], yy[100000];
double cross(int i, int j) {
  return (double)xx[i] * yy[j] - (double)xx[j] * yy[i];
}
int cmp(int i, int j) {
  int sign_i = xx[i] < 0 || xx[i] == 0 && yy[i] < 0,
      sign_j = xx[j] < 0 || xx[j] == 0 && yy[j] < 0;
  double c = cross(i, j);
  return sign_i != sign_j ? sign_i - sign_j
                          : (c != 0 ? (c < 0 ? -1 : 1) : i - j);
}
int bad(int i, int j) {
  double c = cross(i, j);
  return c > 0 || c == 0 && i > j;
}
int zz[1 + 100000], ll[1 + 100000], rr[1 + 100000], kk[1 + 100000], u_, l_, r_;
int node(int k) {
  static int _ = 1;
  zz[_] = rand_();
  kk[_] = k;
  return _++;
}
void split(int u, int k) {
  int c;
  if (u == 0) {
    u_ = l_ = r_ = 0;
    return;
  }
  c = cmp(kk[u], k);
  if (c < 0) {
    split(rr[u], k);
    rr[u] = l_, l_ = u;
  } else if (c > 0) {
    split(ll[u], k);
    ll[u] = r_, r_ = u;
  } else {
    u_ = u, l_ = ll[u], r_ = rr[u];
    ll[u] = rr[u] = 0;
  }
}
int merge(int u, int v) {
  if (u == 0) return v;
  if (v == 0) return u;
  if (zz[u] < zz[v]) {
    rr[u] = merge(rr[u], v);
    return u;
  } else {
    ll[v] = merge(u, ll[v]);
    return v;
  }
}
int first(int u) { return ll[u] == 0 ? u : first(ll[u]); }
int last(int u) { return rr[u] == 0 ? u : last(rr[u]); }
int kbad;
void tr_add(int i) {
  if (u_ == 0)
    u_ = node(i);
  else {
    int l, r;
    split(u_, i);
    l = kk[l_ ? last(l_) : last(r_)], r = kk[r_ ? first(r_) : first(l_)];
    kbad += bad(l, i) + bad(i, r) - bad(l, r);
    u_ = merge(merge(l_, node(i)), r_);
  }
}
void tr_remove(int i) {
  if (ll[u_] == 0 && rr[u_] == 0)
    u_ = 0;
  else {
    int l, r;
    split(u_, i);
    l = kk[l_ ? last(l_) : last(r_)], r = kk[r_ ? first(r_) : first(l_)];
    kbad -= bad(l, i) + bad(i, r) - bad(l, r);
    u_ = merge(l_, r_);
  }
}
int main() {
  int n, q, h, x0, y0, z0, w0, k1;
  long long k2;
  scanf("%d%d%d%d", &x0, &y0, &z0, &q), w0 = x0 + y0 + z0;
  for (h = 0; h < 200000; h++) {
    ox[h] = (long long *)malloc(2 * sizeof *ox[h]);
    oy[h] = (long long *)malloc(2 * sizeof *oy[h]);
    oc[h] = (int *)malloc(2 * sizeof *oc[h]);
  }
  n = 0, k1 = 0, k2 = 0, kbad = 0;
  while (q--) {
    static char s[2];
    scanf("%s", s);
    if (s[0] == 'A') {
      int x, y, z, w;
      long long x_, y_, d;
      scanf("%d%d%d", &x, &y, &z), w = x + y + z;
      x_ = (long long)x * w0 - (long long)x0 * w;
      y_ = (long long)y * w0 - (long long)y0 * w;
      d = gcd(abs_(x_), abs_(y_));
      if (d != 0) x_ /= d, y_ /= d;
      xx[n] = x_, yy[n] = y_, n++;
      if (xx[n - 1] == 0 && yy[n - 1] == 0)
        k1++;
      else {
        k2 += ht_get(-x_, -y_);
        ht_add(x_, y_, 1);
        tr_add(n - 1);
      }
    } else {
      int i;
      scanf("%d", &i), i--;
      if (xx[i] == 0 && yy[i] == 0)
        k1--;
      else {
        ht_add(xx[i], yy[i], -1);
        k2 -= ht_get(-xx[i], -yy[i]);
        tr_remove(i);
      }
    }
    printf(k1 > 0
               ? "1\n"
               : (k2 > 0 ? "2\n"
                         : ((ll[u_] || rr[u_]) && kbad == 0 ? "3\n" : "0\n")));
  }
  return 0;
}