Factory Repairs

A factory produces thimbles in bulk. Typically, it can produce up to a thimbles a day. However, some of the machinery is defective, so it can currently only produce b thimbles each day. The factory intends to choose a k-day period to do maintenance and construction; it cannot produce any thimbles during this time, but will be restored to its full production of a thimbles per day after the k days are complete.

Initially, no orders are pending. The factory receives updates of the form d ia i, indicating that a i new orders have been placed for the d i-th day. Each order requires a single thimble to be produced on precisely the specified day. The factory may opt to fill as many or as few of the orders in a single batch as it likes.

As orders come in, the factory owner would like to know the maximum number of orders he will be able to fill if he starts repairs on a given day p i. Help the owner answer his questions.

Input

The first line contains five integers nkab, and q (1 ≤ k ≤ n ≤ 200 000, 1 ≤ b < a ≤ 10 000, 1 ≤ q ≤ 200 000) — the number of days, the length of the repair time, the production rates of the factory, and the number of updates, respectively.

The next q lines contain the descriptions of the queries. Each query is of one of the following two forms:

  • d i a i (1 ≤ d i ≤ n, 1 ≤ a i ≤ 10 000), representing an update of a i orders on day d i, or
  • p i (1 ≤ p i ≤ n - k + 1), representing a question: at the moment, how many orders could be filled if the factory decided to commence repairs on day p i?

It’s guaranteed that the input will contain at least one query of the second type.

Output

For each query of the second type, print a line containing a single integer — the maximum number of orders that the factory can fill over all n days.

Examples

input

5 2 2 1 8
1 1 2
1 5 3
1 2 1
2 2
1 4 2
1 3 2
2 1
2 3

output

3
6
4

input

5 4 10 1 6
1 1 5
1 5 5
1 3 2
1 5 2
2 1
2 2

output

7
1

Note

Consider the first sample.

We produce up to 1 thimble a day currently and will produce up to 2 thimbles a day after repairs. Repairs take 2 days.

For the first question, we are able to fill 1 order on day 1, no orders on days 2 and 3 since we are repairing, no orders on day 4 since no thimbles have been ordered for that day, and 2 orders for day 5 since we are limited to our production capacity, for a total of 3 orders filled.

For the third question, we are able to fill 1 order on day 1, 1 order on day 2, and 2 orders on day 5, for a total of 4 orders.

Solution:

#include <bits/stdc++.h>

using namespace std;

const int N = 400010;

int s[2][N];
int x[N], y[N];
int n;

inline void modify(int q, int x, int v) {
while (x <= n) {
    s[q][x] += v;
    x = (x | (x - 1)) + 1;
  }
}

inline int find_sum(int q, int x) {
  int v = 0;
  while (x > 0) {
v += s[q][x];
x &= x - 1;
}
return v;
}

int main() {
int k, a, b, tt;
scanf("%d %d %d %d %d", &n, &k, &a, &b, &tt);
for (int i = 1; i <= n; i++) {
    x[i] = 0;
    y[i] = 0;
    s[0][i] = s[1][i] = 0;
  }
  while (tt--) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int day, cnt;
      scanf("%d %d", &day, &cnt);
      int new_x = min(b, x[day] + cnt);
      int new_y = min(a, y[day] + cnt);
      modify(0, day, new_x - x[day]);
      modify(1, day, new_y - y[day]);
      x[day] = new_x;
      y[day] = new_y;
    } else {
      int from;
      scanf("%d", &from);
      int to = from + k - 1;
      int ans = find_sum(0, from - 1);
      ans += find_sum(1, n) - find_sum(1, to);
      printf("%d\n", ans);
    }
  }
  return 0;
}