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;
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &x : v) is >> x;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];
  }
  return os;
}
__int128 dot(const pair<long long, long long> &a,
             const pair<long long, long long> &b) {
  return a.first * (__int128)b.first + a.second * (__int128)b.second;
}
__int128 cross(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return a.first * (__int128)b.second - a.second * (__int128)b.first;
}
struct State {
  int tag;
  pair<long long, long long> axis, u, d;
  void ins(const pair<long long, long long> &vec) {
    if (tag == 0) {
      tag = 1;
      axis = u = d = vec;
    } else if (tag == 1) {
      __int128 delta = cross(axis, vec);
      if (delta > 0 && cross(u, vec) > 0) u = vec;
      if (delta < 0 && cross(d, vec) < 0) d = vec;
      if (cross(u, d) > 0) tag = 2;
    }
  }
};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b, c;
  cin >> a >> b >> c;
  int n;
  cin >> n;
  vector<pair<int, int>> tim;
  vector<pair<long long, long long>> vec;
  long long u1 = a, v1 = b, w1 = c, u2, v2, w2;
  if (a || b) {
    swap(u1, v1);
    v1 *= -1;
    w1 = 0;
  } else {
    swap(u1, w1);
    w1 *= -1;
    v1 = 0;
  }
  u2 = b * w1 - c * v1;
  v2 = c * u1 - a * w1;
  w2 = a * v1 - b * u1;
  for (int i = 0; i < n; ++i) {
    cin.ignore();
    char opt;
    cin >> opt;
    if (opt == 'R') {
      int x;
      cin >> x;
      --x;
      tim[x].second = i - 1;
    } else {
      int x, y, z;
      cin >> x >> y >> z;
      tim.emplace_back(i, n - 1);
      vec.emplace_back(x * u1 + y * v1 + z * w1, x * u2 + y * v2 + z * w2);
    }
  }
  vector<int> ans(n);
  function<void(int, int, const vector<pair<int, int>> &,
                const vector<pair<long long, long long>> &, State)>
      dc = [&](int l, int r, const vector<pair<int, int>> &tm,
               const vector<pair<long long, long long>> &vc, State state) {
        vector<pair<int, int>> tl, tr;
        vector<pair<long long, long long>> vl, vr;
        int mid = (l + r) >> 1;
        for (int i = 0; i < tm.size(); ++i) {
          if (tm[i].first == l && tm[i].second == r)
            state.ins(vc[i]);
          else if (tm[i].second <= mid) {
            tl.push_back(tm[i]);
            vl.push_back(vc[i]);
          } else if (tm[i].first > mid) {
            tr.push_back(tm[i]);
            vr.push_back(vc[i]);
          } else {
            tl.emplace_back(tm[i].first, mid);
            vl.push_back(vc[i]);
            tr.emplace_back(mid + 1, tm[i].second);
            vr.push_back(vc[i]);
          }
        }
        if (l == r) {
          if (state.tag == 2) ans[l] = 3;
        } else {
          dc(l, mid, tl, vl, state);
          dc(mid + 1, r, tr, vr, state);
        }
      };
  State state = State();
  dc(0, n - 1, tim, vec, state);
  vector<int> sum(n + 1);
  for (int i = 0; i < vec.size(); ++i) {
    long long g = gcd(vec[i].first, vec[i].second);
    if (g < 0) g = -g;
    if (g > 0) {
      vec[i].first /= g;
      vec[i].second /= g;
    } else {
      ++sum[tim[i].first];
      --sum[tim[i].second + 1];
    }
  }
  auto reg = [&](pair<long long, long long> vec) {
    if (vec.first < 0) {
      vec.first = -vec.first;
      vec.second = -vec.second;
    } else if (vec.first == 0 && vec.second < 0) {
      vec.second = -vec.second;
    }
    return vec;
  };
  auto id = [&](const pair<long long, long long> &vec) {
    static map<pair<long long, long long>, int> mp;
    static int cnt = 0;
    auto it = mp.find(vec);
    if (it != mp.end()) return it->second;
    mp.insert(make_pair(vec, cnt++));
    return cnt - 1;
  };
  vector<int> gi(n), sgn(n);
  for (int i = 0; i < vec.size(); ++i) {
    gi[i] = id(reg(vec[i]));
    sgn[i] = reg(vec[i]) == vec[i];
  }
  vector<vector<int>> ins(n + 1), del(n + 1);
  for (int i = 0; i < vec.size(); ++i) {
    ins[tim[i].first].push_back(gi[i] * 2 + sgn[i]);
    del[tim[i].second + 1].push_back(gi[i] * 2 + sgn[i]);
  }
  vector<int> cnt(n * 2);
  int pairs = 0;
  for (int i = 0; i < n; ++i) {
    for (int j : ins[i]) {
      if (cnt[j]++ == 0 && cnt[j ^ 1]) ++pairs;
    }
    for (int j : del[i]) {
      if (--cnt[j] == 0 && cnt[j ^ 1]) --pairs;
    }
    if (pairs) ans[i] = 2;
  }
  for (int i = 1; i < n; ++i) sum[i] += sum[i - 1];
  for (int i = 0; i < n; ++i)
    if (sum[i]) ans[i] = 1;
  cout << ans << '\n';
  return 0;
}