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>
int chkmax(T &a, T b) {
  if (b > a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
int chkmin(T &a, T b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class iterator>
void output(iterator begin, iterator end, ostream &out = cerr) {
  while (begin != end) {
    out << (*begin) << " ";
    begin++;
  }
  out << endl;
}
template <class T>
void output(T x, ostream &out = cerr) {
  output(x.begin(), x.end(), out);
}
void fast_io() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const int dim = 3;
const vector<long long> BAD = {-1, -1, -1};
const vector<long long> GOOD = {-2, -2, -2};
vector<long long> target;
int q;
vector<vector<long long> > a;
vector<int> is_zero;
vector<pair<int, int> > Q;
int check_good(const vector<long long> &vec) {
  __int128 x1 = vec[1] * target[0];
  __int128 y1 = vec[2] * target[0];
  __int128 tx = target[1] * vec[0];
  __int128 ty = target[2] * vec[0];
  return (x1 == tx && y1 == ty);
}
void read() {
  int dim0 = -1;
  target.resize(dim);
  for (int i = 0; i < dim; ++i) {
    cin >> target[i];
    if (target[i] && dim0 == -1) {
      dim0 = i;
    }
  }
  swap(target[dim0], target[0]);
  cin >> q;
  vector<long long> new_vec(dim);
  for (int i = 0; i < q; ++i) {
    char c;
    cin >> c;
    if (c == 'A') {
      int cur_is_zero = 0;
      for (int j = 0; j < dim; ++j) {
        cin >> new_vec[j];
      }
      swap(new_vec[dim0], new_vec[0]);
      if (new_vec[0] == 0) {
        cur_is_zero = 1;
        new_vec[0] = 1;
      }
      int bad = 0;
      for (int j = 0; j < dim; ++j) {
        if (target[j] == 0 && new_vec[j] != 0) {
          bad = 1;
        }
      }
      int good = 0;
      if (bad == 0 && cur_is_zero == 0) {
        good = check_good(new_vec);
      }
      Q.emplace_back(a.size(), 0);
      a.push_back(bad ? BAD : (good ? GOOD : new_vec));
      is_zero.push_back(cur_is_zero);
    } else {
      int id;
      cin >> id;
      id--;
      Q.emplace_back(id, 1);
    }
  }
}
void print_stupid(int id) {
  if (a[id] == BAD) {
    cerr << "bad" << endl;
    return;
  }
  if (a[id] == GOOD) {
    cerr << "good" << endl;
    return;
  }
  long double x1 = (long double)a[id][1] / (long double)a[id][0];
  long double y1 = (long double)a[id][2] / (long double)a[id][0];
  long double tx = (long double)target[1] / (long double)target[0];
  long double ty = (long double)target[2] / (long double)target[0];
  if (is_zero[id] == 0) {
    x1 -= tx;
    y1 -= ty;
  }
  cerr << x1 << " " << y1 << endl;
}
int sign(__int128 a) { return (a < 0 ? -1 : (a > 0)); }
int cross_sign(int id1, int id2) {
  __int128 x1 = a[id1][1] * target[0] * a[id2][0];
  __int128 y1 = a[id1][2] * target[0] * a[id2][0];
  __int128 x2 = a[id2][1] * target[0] * a[id1][0];
  __int128 y2 = a[id2][2] * target[0] * a[id1][0];
  __int128 tx = target[1] * a[id1][0] * a[id2][0];
  __int128 ty = target[2] * a[id1][0] * a[id2][0];
  if (is_zero[id1] == 0) {
    x1 -= tx;
    y1 -= ty;
  }
  if (is_zero[id2] == 0) {
    x2 -= tx;
    y2 -= ty;
  }
  __int128 cross = (x1 * y2 - x2 * y1);
  return sign(cross);
}
int dot_sign(int id1, int id2) {
  __int128 x1 = a[id1][1] * target[0] * a[id2][0];
  __int128 y1 = a[id1][2] * target[0] * a[id2][0];
  __int128 x2 = a[id2][1] * target[0] * a[id1][0];
  __int128 y2 = a[id2][2] * target[0] * a[id1][0];
  __int128 tx = target[1] * a[id1][0] * a[id2][0];
  __int128 ty = target[2] * a[id1][0] * a[id2][0];
  if (is_zero[id1] == 0) {
    x1 -= tx;
    y1 -= ty;
  }
  if (is_zero[id2] == 0) {
    x2 -= tx;
    y2 -= ty;
  }
  __int128 dot = (x1 * x2 + y1 * y2);
  return sign(dot);
}
pair<int, int> get_coord_signs(int id) {
  __int128 x1 = a[id][1] * target[0];
  __int128 y1 = a[id][2] * target[0];
  __int128 tx = target[1] * a[id][0];
  __int128 ty = target[2] * a[id][0];
  if (!is_zero[id]) {
    x1 -= tx;
    y1 -= ty;
  }
  return {sign(x1), sign(y1)};
}
bool cmp(int id1, int id2) { return cross_sign(id1, id2) == 1; }
int good_cnt = 0;
int is_upper(pair<int, int> S) {
  return (S.first > 0 || (S.first == 0 && S.second > 0));
}
bool polar_cmp(int id1, int id2) {
  int t1 = is_upper(get_coord_signs(id1));
  int t2 = is_upper(get_coord_signs(id2));
  if (t1 > t2) {
    return 0;
  }
  if (t1 < t2) {
    return 1;
  }
  return cross_sign(id1, id2) == 1;
}
vector<int> order, classId, classRep, revClass, cnt;
void build() {
  int AP = a.size();
  for (int i = 0; i < AP; ++i) {
    if (a[i] != GOOD && a[i] != BAD) {
      order.push_back(i);
    }
  }
  sort(order.begin(), order.end(), polar_cmp);
  int cur_class_id = 0;
  classId.resize(AP);
  for (int i = 1; i < order.size(); ++i) {
    if (polar_cmp(order[i - 1], order[i])) {
      cur_class_id++;
    }
    classId[order[i]] = cur_class_id;
  }
  classRep.resize(cur_class_id + 1);
  for (auto x : order) {
    classRep[classId[x]] = x;
  }
  int classCnt = cur_class_id + 1;
  revClass.resize(classCnt);
  for (int i = 0; i < classCnt; ++i) {
    int l = 1, r = classCnt;
    while (l < r) {
      int mid = (l + r) >> 1;
      if (cross_sign(classRep[i], classRep[(i + mid) % classCnt]) != 1) {
        r = mid;
      } else {
        l = mid + 1;
      }
    }
    if (l != classCnt &&
        cross_sign(classRep[i], classRep[(i + l) % classCnt]) == 0) {
      revClass[i] = (i + l) % classCnt;
    } else {
      revClass[i] = -1;
    }
  }
  cnt.resize(classCnt);
}
multiset<int> upper, lower;
long long pair2;
void make_change(int id, int type) {
  if (a[id] == BAD) {
    return;
  }
  if (a[id] == GOOD) {
    good_cnt += (type == 0 ? 1 : -1);
  }
  int cl = classId[id];
  if (type == 0) {
    if (revClass[cl] != -1) {
      pair2 += cnt[revClass[cl]];
    }
    cnt[cl]++;
    if (is_upper(get_coord_signs(id))) {
      upper.insert(classId[id]);
    } else {
      lower.insert(classId[id]);
    }
  } else {
    if (revClass[cl] != -1) {
      pair2 -= cnt[revClass[cl]];
    }
    cnt[cl]--;
    if (is_upper(get_coord_signs(id))) {
      upper.erase(upper.find(classId[id]));
    } else {
      lower.erase(lower.find(classId[id]));
    }
  }
}
int get() {
  if (good_cnt) {
    return 1;
  }
  if (pair2) {
    return 2;
  }
  if (!upper.empty() && !lower.empty()) {
    int t1 = classRep[(*upper.begin())];
    int t2 = classRep[(*prev(upper.end()))];
    int t3 = classRep[(*lower.begin())];
    int t4 = classRep[(*prev(lower.end()))];
    if (cross_sign(t4, t1) == 1 && cross_sign(t2, t3) == 1) {
      return 3;
    }
  }
  return 0;
}
void process() {
  for (int i = 0; i < q; ++i) {
    make_change(Q[i].first, Q[i].second);
    int res = get();
    cout << res << '\n';
  }
}
signed main() {
  fast_io();
  cerr << setprecision(4) << fixed;
  read();
  build();
  process();
}