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;
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
struct point {
  long long x, y;
  point() : x(0), y(0) {}
  point(long long x, long long y) : x(x), y(y) {}
  int half() const {
    if (y > 0 || (y == 0 && x > 0)) return 1;
    return 2;
  }
  friend __int128 operator^(const point& p1, const point& p2) {
    return (__int128)p1.x * (__int128)p2.y - (__int128)p2.x * (__int128)p1.y;
  }
  friend __int128 operator*(const point& p1, const point& p2) {
    return (__int128)p1.x * (__int128)p2.x + (__int128)p1.y * (__int128)p2.y;
  }
};
struct cmp {
  bool operator()(const point& p1, const point& p2) const {
    int h1 = p1.half();
    int h2 = p2.half();
    if (h1 != h2) return h1 < h2;
    __int128 mul = p1 ^ p2;
    if (mul != 0) return mul > 0;
    return p1 * p1 < p2 * p2;
  }
};
struct solver2 {
  int cnt_good;
  map<pair<long long, long long>, int> cnt;
  solver2() = default;
  void add(point p) {
    long long x = p.x;
    long long y = p.y;
    if (y < 0 || (y == 0 && x < 0)) {
      x = -x;
      y = -y;
    }
    cnt[make_pair(x, y)]++;
    if (cnt[make_pair(x, y)] == 2) cnt_good++;
  }
  void del(point p) {
    long long x = p.x;
    long long y = p.y;
    if (y < 0 || (y == 0 && x < 0)) {
      x = -x;
      y = -y;
    }
    cnt[make_pair(x, y)]--;
    if (cnt[make_pair(x, y)] == 1) cnt_good--;
  }
  bool check() { return (cnt_good > 0); }
};
struct solver3 {
  set<point, cmp> q;
  solver3() = default;
  void add(point p) { q.insert(p); }
  void del(point p) { q.erase(p); }
  bool check() {
    if (q.size() == 1) return false;
    point p = *q.begin();
    p.x = -p.x;
    p.y = -p.y;
    auto it = q.lower_bound(p);
    if (it == q.end()) it = q.begin();
    point s0 = *it;
    if (it == q.begin()) it = q.end();
    it--;
    point s1 = *it;
    if ((s0 ^ s1) > 0) return false;
    return true;
  }
};
struct backend {
  solver2 s2;
  solver3 s3;
  backend() = default;
  void add(point p) {
    s2.add(p);
    s3.add(p);
  }
  void del(point p) {
    s2.del(p);
    s3.del(p);
  }
  int solve() {
    if (s2.check()) return 2;
    if (s3.check()) return 3;
    return 0;
  }
};
struct helper {
  int total;
  int cnt0;
  map<pair<long long, long long>, int> cur;
  backend b;
  helper() = default;
  void add(long long x, long long y) {
    total++;
    if (x == 0 && y == 0) {
      cnt0++;
      return;
    }
    long long g = gcd(abs(x), abs(y));
    x /= g;
    y /= g;
    cur[make_pair(x, y)]++;
    if (cur[make_pair(x, y)] == 1) b.add(point(x, y));
  }
  void del(long long x, long long y) {
    total--;
    if (x == 0 && y == 0) {
      cnt0--;
      return;
    }
    long long g = gcd(abs(x), abs(y));
    x /= g;
    y /= g;
    cur[make_pair(x, y)]--;
    if (cur[make_pair(x, y)] == 0) b.del(point(x, y));
  }
  int solve() {
    if (cnt0 > 0) return 1;
    if (total == 0) return 0;
    return b.solve();
  }
};
int q;
tuple<long long, long long, long long> v0;
vector<tuple<long long, long long, long long> > v;
tuple<long long, long long, long long> read() {
  long long x, y, z;
  cin >> x >> y >> z;
  return make_tuple(x, y, z);
}
helper h;
pair<long long, long long> getpoint(tuple<long long, long long, long long> p) {
  long long z0 = get<0>(p) * get<1>(v0) - get<1>(p) * get<0>(v0);
  long long y0 = get<0>(p) * get<2>(v0) - get<2>(p) * get<0>(v0);
  long long x0 = get<1>(p) * get<2>(v0) - get<2>(p) * get<1>(v0);
  if (get<0>(v0) != 0) return make_pair(y0, z0);
  if (get<1>(v0) != 0) return make_pair(x0, z0);
  return make_pair(x0, y0);
}
void add(tuple<long long, long long, long long> p) {
  pair<long long, long long> cur = getpoint(p);
  h.add(cur.first, cur.second);
}
void del(tuple<long long, long long, long long> p) {
  pair<long long, long long> cur = getpoint(p);
  h.del(cur.first, cur.second);
}
int solve() { return h.solve(); }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  v0 = read();
  cin >> q;
  for (int i = 0; i < q; i++) {
    char x;
    cin >> x;
    if (x == 'A') {
      v.push_back(read());
      add(v.back());
    } else {
      int id;
      cin >> id;
      del(v[id - 1]);
    }
    cout << solve() << "\n";
  }
  return 0;
}