Phoenix wonders what it is like to rob diamonds from a jewelry store!

There are n types of diamonds. The i-th type has weight w_i and value v_i. The store initially has a_i diamonds of the i-th type.

Each day, for q days, one of the following will happen: 

  1. A new shipment of k_i diamonds of type d_i arrive. 
  2. The store sells k_i diamonds of type d_i. 
  3. Phoenix wonders what will happen if he robs the store using a bag that can fit diamonds with total weight not exceeding c_i. If he greedily takes diamonds of the largest value that fit, how much value would be taken? If there are multiple diamonds with the largest value, he will take the one with minimum weight. If, of the diamonds with the largest value, there are multiple with the same minimum weight, he will take any of them. 



Of course, since Phoenix is a law-abiding citizen, this is all a thought experiment and he never actually robs any diamonds from the store. This means that queries of type 3 do not affect the diamonds in the store.

Input

The first line contains two integers n and q (1 ≤ n ≤ 2 ⋅ 10^5; 1 ≤ q ≤ 10^5) — the number of types of diamonds and number of days, respectively.

The next n lines describe each type of diamond. The i-th line will contain three integers a_i, w_i, and v_i (0 ≤ a_i ≤ 10^5; 1 ≤ w_i, v_i ≤ 10^5) — the initial number of diamonds of the i-th type, the weight of diamonds of the i-th type, and the value of diamonds of the i-th type, respectively.

The next q lines contain the queries. For each query, the first integer of each line is t (1 ≤ t ≤ 3) — the type of query.

If t=1, then two integers k_i, d_i follow (1 ≤ k_i ≤ 10^5; 1 ≤ d_i ≤ n). This means that a new shipment of k_i diamonds arrived, each of type d_i.

If t=2, then two integers k_i, d_i follow (1 ≤ k_i ≤ 10^5; 1 ≤ d_i ≤ n). This means that the store has sold k_i diamonds, each of type d_i. It is guaranteed that the store had the diamonds before they sold them.

If t=3, an integer c_i will follow (1 ≤ c_i ≤ 10^{18}) — the weight capacity of Phoenix's bag.

It is guaranteed that there is at least one query where t=3.

Output

Print the answer for each query of the third type (t=3).

Example

Input


3 5
2 3 4
1 5 1
0 2 4
3 6
1 3 3
3 10
2 2 3
3 30


Output


8
16
13

Note

For the first query where t=3, Phoenix can fit 2 diamonds of type 1, with total weight 6 and value 8.

For the second query where t=3, Phoenix will first fit in 3 diamonds of type 3, then one diamond of type 1 for a total weight of 9 and a value of 16. Note that diamonds of type 3 are prioritized over type 1 because type 3 has equal value but less weight.

For the final query where t=3, Phoenix can fit every diamond for a total value of 13.
#include <bits/stdc++.h>
typedef long long i64;
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define per(i, a, b) for (int i = (b) - 1; i >= (a); --i)
using namespace std;

const int xn = 2e5, xk = 60;
int n, nq, o[xn];
struct jewel {i64 s; int w, v, i;} a[xn];
#define fk while (-1 != k and (1ll << k) > c) {--k;}

const int xns = xn * 2;
int ns, ls[xns], rs[xns]; 
i64 sw[xns][xk + 1], sv[xns][xk + 1], mn[xns][xk];
void pu(int u, int l = -1) {
  if (-1 != l) {
    i64 wi = a[l].s * a[l].w, vi = a[l].s * a[l].v;
    i64 c = a[l].w; int k = xk - 1; fk;
    rep(i, 0, xk + 1) {
      if (i > k) {sw[u][i] = wi; sv[u][i] = vi;}
      else {sw[u][i] = sv[u][i] = 0;}
    }
    rep(i, 0, xk) {mn[u][i] = 1ll << (i + 1);}
    if (a[l].s) {mn[u][k] = c;}
  } else {
    rep(i, 0, xk + 1) {
      sw[u][i] = sw[ls[u]][i] + sw[rs[u]][i];
      sv[u][i] = sv[ls[u]][i] + sv[rs[u]][i];
    }
    rep(i, 0, xk) {
      mn[u][i] = min(mn[ls[u]][i],
       sw[ls[u]][i] + mn[rs[u]][i]);
    }
  }
}
int nw(int l, int r) {
  int u = ns++; 
  if (r - l == 1) {pu(u, l); return u;}
  int mid = (l + r) / 2;
  ls[u] = nw(l, mid); rs[u] = nw(mid, r);
  pu(u); return u;
}
void mf(int x, int u, int l, int r) {
  if (r - l == 1) {pu(u, l); return;}
  int mid = (l + r) / 2;
  if (x < mid) {mf(x, ls[u], l, mid);}
  else {mf(x, rs[u], mid, r);}
  pu(u);
}
i64 c; int k;
i64 bs(int u, int l, int r) {
  if (-1 == k) {return 0ll;}
  if (r - l == 1) {
    i64 x = min(a[l].s, c / a[l].w);
    c -= x * a[l].w; fk;
    return x * a[l].v;
  }
  int mid = (l + r) / 2; i64 res = 0;
  if (c - sw[ls[u]][k] < (1ll << k) or
   mn[ls[u]][k] <= c) {res += bs(ls[u], l, mid);}
  else {c -= sw[ls[u]][k]; res += sv[ls[u]][k];}
  res += bs(rs[u], mid, r);
  return res;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n >> nq;
  rep(i, 0, n) {
    cin >> a[i].s >> a[i].w >> a[i].v; a[i].i = i;
  }
  sort(a, a + n, [&](jewel &p, jewel &q) {
    return p.v != q.v ? p.v > q.v : p.w < q.w;
  });
  rep(i, 0, n) {o[a[i].i] = i;}
  int rt = nw(0, n); 
  rep(iq, 0, nq) {
    int t; cin >> t;
    if (t == 3) {
      cin >> c; k = xk - 1; fk;
      cout << bs(rt, 0, n) << '\n';
    } else {
      int k, i; cin >> k >> i; --i; i = o[i];
      t == 1 ? a[i].s += k : a[i].s -= k;
      mf(i, rt, 0, n);
    }
  }
  return 0;
}

/* 📌https://www.cnblogs.com/George1123/p/tips.html */