Problem: 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.

Solution (in CPP):

Solution:
// author: xay5421
// created: Mon May  3 17:34:21 2021
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long LL;
const LL INFLL=0X3F3F3F3F3F3F3F3FLL;
const int N=200005;
int n,Q,_w[N],_v[N],id[N],_id[N];
LL _a[N],sw0[N*4][18],sv0[N*4][18],sw1[N*4][18],sv1[N*4][18];
void bud(int k1,int k2,int k3,int k4,int k5){
	if(k2>k5||k3<k4)return;
	if(k2==k3){
		rep(k,1,17){
			if(_w[id[k2]]<(1<<k)){
				sw0[k1][k]=_a[id[k2]]*_w[id[k2]];
				sv0[k1][k]=_a[id[k2]]*_v[id[k2]];
			}
			sw1[k1][k]=sv1[k1][k]=INFLL;
			if(_w[id[k2]]>=(1<<(k-1))&&_w[id[k2]]<(1<<k)&&_a[id[k2]]){
				sw1[k1][k]=_w[id[k2]];
				sv1[k1][k]=_v[id[k2]];
			}
		}
		return;
	}
	int mid=(k2+k3)>>1;
	bud(k1*2,k2,mid,k4,k5),bud(k1*2+1,mid+1,k3,k4,k5);
	rep(k,1,17){
		sw0[k1][k]=sw0[k1*2][k]+sw0[k1*2+1][k];
		sv0[k1][k]=sv0[k1*2][k]+sv0[k1*2+1][k];
		if(sw1[k1*2][k]<sw0[k1*2][k-1]+sw1[k1*2+1][k]){
			sw1[k1][k]=sw1[k1*2][k];
			sv1[k1][k]=sv1[k1*2][k];
		}else{
			sw1[k1][k]=sw0[k1*2][k-1]+sw1[k1*2+1][k];
			sv1[k1][k]=sv0[k1*2][k-1]+sv1[k1*2+1][k];
		}
	}
}
void add(int x,int y){
	_a[x]+=y;
	bud(1,1,n,_id[x],_id[x]);
}
LL rem,vv; int _k;
void clip(){
	while(_k>0&&(1<<(_k-1))>rem)--_k;
}
void qry(int k1,int k2,int k3){
	if(k2==k3){
		LL tt=min(_a[id[k2]],rem/_w[id[k2]]);
		rem-=tt*_w[id[k2]];
		vv+=tt*_v[id[k2]];
		return;
	}
	int mid=(k2+k3)>>1;
	clip();
	if(sw0[k1][_k]<=rem){
		rem-=sw0[k1][_k];
		vv+=sv0[k1][_k];
		return;
	}
	if(sw1[k1][_k]>rem&&sw0[k1][_k-1]<=rem){
		rem-=sw0[k1][_k-1];
		vv+=sv0[k1][_k-1];
		return;
	}
	qry(k1*2,k2,mid);
	clip();
	qry(k1*2+1,mid+1,k3);
}
void sol(LL x){
	_k=17,rem=x,vv=0;
	clip();
	qry(1,1,n);
	printf("%lld\n",vv);
}
int main(){
#ifdef xay5421
	freopen("a.in","r",stdin);
#endif
	scanf("%d%d",&n,&Q);
	rep(i,1,n){
		scanf("%lld%d%d",&_a[i],&_w[i],&_v[i]);
		id[i]=i;
	}
	sort(id+1,id+1+n,[&](int x,int y){return _v[x]^_v[y]?_v[x]>_v[y]:_w[x]<_w[y];});
	rep(i,1,n)_id[id[i]]=i;
	bud(1,1,n,1,n);
	while(Q--){
		int t;
		scanf("%d",&t);
		if(t==1){
			int x,y;
			scanf("%d%d",&x,&y);
			add(y,x);
		}else if(t==2){
			int x,y;
			scanf("%d%d",&x,&y);
			add(y,-x);
		}else{
			LL x;
			scanf("%lld",&x);
			sol(x);
		}
	}
	return 0;
}