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>
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
using namespace std;
mt19937 rnd(time(0) + 228 + 'k' + 'e' + 'k' + 'e' + 'r' + 'o' + 'f' + 'e' +
            'y');
vector<int> genvec(int sz, int minelem, int maxelem) {
  ++maxelem;
  vector<int> ans(sz);
  for (int i = 0; i < sz; ++i) {
    ans[i] = minelem + rnd() % (maxelem - minelem);
  }
  return ans;
}
const long double EPS = 1e-11;
bool checkprime(int x) {
  for (int i = 2; i * i <= x; ++i)
    if (x % i == 0) return 0;
  return 1;
}
const long double PI = acos(-1);
const int MOD7 = 1000000007;
const int MOD9 = 1000000009;
const long long INF = 2e18;
int mod = MOD7;
const int inf = 1e9;
const int MAXN = 1e5 + 228;
struct point {
  long double x, y;
};
inline point operator-(point a, point b) { return {a.x - b.x, a.y - b.y}; }
inline long double operator*(point a, point b) { return a.x * b.y - a.y * b.x; }
inline long double len(point a) { return ((a.x) * (a.x)) + ((a.y) * (a.y)); }
inline bool cmp(point a, point b) {
  long double xx = a * b;
  if (abs(xx) < EPS) return len(a) < len(b);
  return xx > 0;
}
point st[MAXN];
int sts = 0;
point a[MAXN];
int nsz = 0;
void ch() {
  point kek = {inf, inf};
  for (int i = 0; i < nsz; ++i) {
    if (a[i].x < kek.x || (abs(a[i].x - kek.x) < EPS && a[i].y < kek.y))
      kek = a[i];
  }
  for (int i = 0; i < nsz; ++i) a[i] = a[i] - kek;
  sts = 0;
  sort(a, a + nsz, cmp);
  for (int i = 0; i < nsz; ++i) {
    while (sts > 1 &&
           (st[sts - 2] - st[sts - 1]) * (a[i] - st[sts - 1]) >= -EPS) {
      sts--;
    }
    st[sts++] = a[i];
  }
  for (int i = 0; i < sts; ++i) st[i].x += kek.x, st[i].y += kek.y;
}
inline long double dist(point a, point b) { return sqrt(len(a - b)); }
inline bool belong(point a, point b, point c) {
  return abs((b - a) * (c - a)) < EPS && b.x >= min(a.x, c.x) &&
         b.x <= max(a.x, c.x) && b.y >= min(a.y, c.y) && b.y <= max(a.y, c.y);
}
long double operator%(point a, point b) { return a.x * b.x + a.y * b.y; }
inline int sgn(long double x) { return (abs(x) < EPS ? 0 : (x > 0 ? 1 : -1)); }
inline bool belpol(point check) {
  if (sts < 3) return 0;
  int ff = 0;
  for (int i = 0; i < sts; ++i) {
    int xx = sgn((st[i] - check) * (st[(i + 1) % sts] - check));
    if (xx) {
      if (ff && xx != ff) return 0;
      ff = xx;
    }
  }
  return 1;
}
inline bool operator==(point a, point b) {
  return abs(a.x - b.x) < EPS && abs(a.y - b.y) < EPS;
}
inline bool operator<(point a, point b) { return cmp(a, b); }
inline point operator+(point a, point b) { return {a.x + b.x, a.y + b.y}; }
int sign(long double x) {
  if (x < -EPS) return -1;
  if (x > EPS) return 1;
  return 0;
}
struct kekkek {
  pair<long double, long double> a;
};
bool operator<(kekkek a, kekkek b) {
  if (sign(a.a.first - b.a.first) == 0)
    return abs(a.a.second - b.a.second) != 0 && a.a.second < b.a.second;
  return a.a.first < b.a.first;
}
bool operator==(kekkek a, kekkek b) {
  return sign(a.a.first - b.a.first) == 0 && sign(a.a.second - b.a.second) == 0;
}
bool used[MAXN];
int ptsz = 0;
point points[MAXN];
int n;
point ss;
multiset<point> rofl;
int cnt2 = 0;
map<kekkek, int> wtf[4];
int quarters[MAXN];
int getquarter(point a) {
  if (abs(a.x) < EPS && abs(a.y) < EPS) return 4;
  if (a.x > EPS && (abs(a.y) <= EPS || a.y > 0)) return 0;
  if ((abs(a.x) < EPS || a.x < 0) && a.y >= EPS) return 1;
  if (a.x < 0 && (abs(a.y) < EPS || a.y < 0)) return 2;
  return 3;
}
int getanother(int x) { return (x < 2 ? x + 2 : x - 2); }
kekkek hves[MAXN];
struct fuckit {
  long double x;
};
bool operator<(fuckit a, fuckit b) { return a.x + EPS < b.x; }
multiset<fuckit> keker;
int cntkek = 1;
long double getangle(point aa) {
  point nw = {1, 0};
  long double xx = atan2(nw * aa, nw % aa);
  if (xx < 0) return xx + PI * 2;
  return xx;
}
long double getss(long double a, long double b) {
  if (a <= b + EPS) return b - a;
  return 2 * PI - a + b;
}
void add(fuckit xxx) {
  if (!cntkek) {
    keker.insert(xxx);
    return;
  }
  keker.insert(xxx);
  if (keker.size() < 3) return;
  if (keker.find(xxx) == keker.end())
    while (1)
      ;
  auto fs = (keker.find(xxx) == keker.begin() ? (--keker.end())
                                              : (--keker.find(xxx)));
  auto nexts = (keker.find(xxx) == (--keker.end()) ? keker.begin()
                                                   : (++keker.find(xxx)));
  if (getss((*fs).x, (*nexts).x) > PI && getss((*fs).x, xxx.x) < PI &&
      getss(xxx.x, (*nexts).x) < PI)
    cntkek--;
}
void del(fuckit xxx) {
  if (keker.find(xxx) == keker.end())
    while (1)
      ;
  if (cntkek) {
    keker.erase(keker.find(xxx));
    return;
  }
  auto fs = (keker.find(xxx) == keker.begin() ? (--keker.end())
                                              : (--keker.find(xxx)));
  auto nexts = (keker.find(xxx) == (--keker.end()) ? keker.begin()
                                                   : (++keker.find(xxx)));
  if (getss((*fs).x, (*nexts).x) > PI) ++cntkek;
  keker.erase(keker.find(xxx));
}
map<pair<pair<int, int>, int>, int> cntkekers;
int gcd(int a, int b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
pair<pair<int, int>, int> lols[MAXN];
signed main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  srand(time(NULL));
  int xx, yy, zz;
  cin >> xx >> yy >> zz;
  int ggg = gcd(gcd(xx, yy), zz);
  xx /= ggg;
  yy /= ggg;
  zz /= ggg;
  ss = {(long double)xx / (xx + yy + zz), (long double)yy / (xx + yy + zz)};
  cin >> n;
  for (int i = 0; i < n; ++i) {
    char r;
    cin >> r;
    if (r == 'A') {
      int x, y, z;
      cin >> x >> y >> z;
      ggg = gcd(gcd(x, y), z);
      x /= ggg;
      y /= ggg;
      z /= ggg;
      lols[ptsz] = {{x, y}, z};
      cntkekers[{{x, y}, z}]++;
      point now = {(long double)x / (x + y + z), (long double)y / (x + y + z)};
      point nww = now - ss;
      int xxx = getquarter(nww);
      add({getangle(nww)});
      quarters[ptsz] = xxx;
      if (xxx < 4) {
        int ant = getanother(xxx);
        kekkek hve;
        hve.a =
            (sign(nww.x) == 0
                 ? make_pair((long double)2281337 + 1234 + 0.69, (long double)0)
                 : make_pair((long double)nww.y / nww.x, (long double)0));
        cnt2 += wtf[ant][hve];
        hves[ptsz] = hve;
        wtf[xxx][hve]++;
      }
      rofl.insert(now);
      points[ptsz++] = now;
      ;
    } else {
      int x;
      cin >> x;
      if (used[x - 1]) assert(0);
      used[x - 1] = 1;
      del({getangle(points[x - 1] - ss)});
      cntkekers[lols[x - 1]]--;
      if (quarters[x - 1] != 4) {
        int jj = getanother(quarters[x - 1]);
        cnt2 -= wtf[jj][hves[x - 1]];
        wtf[quarters[x - 1]][hves[x - 1]]--;
        if (wtf[quarters[x - 1]][hves[x - 1]] < 0) assert(0);
      }
    }
    bool ff = (cntkekers[{{xx, yy}, zz}] > 0);
    if (ff) {
      cout << 1 << '\n';
      continue;
    }
    bool f = (cnt2 > 0);
    if (f) {
      cout << 2 << '\n';
      continue;
    }
    bool tf = 1;
    if (keker.size() < 3) {
      cout << 0 << '\n';
      continue;
    }
    if (!cntkek)
      cout << 3 << '\n';
    else
      cout << 0 << '\n';
  }
}