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:
#include <cstdio>
#include <algorithm>
typedef long long ll;
const int Maxn=200000;
const int Maxk=18;
const ll Inf=0x3f3f3f3f3f3f3f3fll;
struct Node{
	int num,w,v,id;
	friend bool operator <(Node a,Node b){
		if(a.v==b.v){
			return a.w<b.w;
		}
		return a.v>b.v;
	}
}a[Maxn+5];
int n,q;
int pos[Maxn+5];
ll num[Maxn+5];
struct Segment_Node{
	ll v[Maxk+1],w[Maxk+1],c[Maxk+5];
}seg[Maxn<<2|5];
void get_val(Segment_Node &val,int id){
	for(int i=1;i<=Maxk;i++){
		val.v[i]=val.w[i]=0;
		val.c[i]=Inf;
		if(a[id].w<(1<<(i-1))){
			val.v[i]=1ll*num[id]*a[id].v;
			val.w[i]=1ll*num[id]*a[id].w;
		}
		else if(a[id].w<(1<<i)&&num[id]>0){
			val.c[i]=a[id].w;
		}
	}
}
void push_up(int root){
	for(int i=1;i<=Maxk;i++){
		seg[root].v[i]=seg[root<<1].v[i]+seg[root<<1|1].v[i];
		seg[root].w[i]=seg[root<<1].w[i]+seg[root<<1|1].w[i];
		seg[root].c[i]=std::min(seg[root<<1].c[i],seg[root<<1].w[i]+seg[root<<1|1].c[i]);
	}
}
void build(int root=1,int left=1,int right=n){
	if(left==right){
		get_val(seg[root],left);
		return;
	}
	int mid=(left+right)>>1;
	build(root<<1,left,mid);
	build(root<<1|1,mid+1,right);
	push_up(root);
}
void update(int x,int a,int root=1,int left=1,int right=n){
	if(left==right){
		num[left]+=a;
		get_val(seg[root],left);
		return;
	}
	int mid=(left+right)>>1;
	if(x<=mid){
		update(x,a,root<<1,left,mid);
	}
	else{
		update(x,a,root<<1|1,mid+1,right);
	}
	push_up(root);
}
void get_cur_dep(ll v,int &dep){
	while(dep>1&&(1<<(dep-2))>v){
		dep--;
	}
}
ll query(ll &v,int &dep,int root=1,int left=1,int right=n){
	if(left==right){
		ll tmp=std::min(num[left],v/a[left].w);
		v-=tmp*a[left].w;
		get_cur_dep(v,dep);
		return tmp*a[left].v;
	}
	if(seg[root].w[dep]<=v){
		ll ans=seg[root].v[dep];
		v-=seg[root].w[dep];
		get_cur_dep(v,dep);
		return ans;
	}
	if(seg[root].w[dep-1]<=v&&v<seg[root].c[dep-1]){
		ll ans=seg[root].v[dep-1];
		v-=seg[root].w[dep-1];
		get_cur_dep(v,dep);
		return ans;
	}
	int mid=(left+right)>>1;
	return query(v,dep,root<<1,left,mid)+query(v,dep,root<<1|1,mid+1,right);
}
int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&a[i].num,&a[i].w,&a[i].v);
		a[i].id=i;
	}
	std::sort(a+1,a+1+n);
	for(int i=1;i<=n;i++){
		pos[a[i].id]=i;
		num[i]=a[i].num;
	}
	build();
	for(int t=1;t<=q;t++){
		int op;
		scanf("%d",&op);
		if(op==1||op==2){
			op=(op==1?1:-1);
			int x,v;
			scanf("%d%d",&v,&x);
			update(pos[x],op*v);
		}
		else{
			ll w;
			scanf("%lld",&w);
			int dep=18;
			get_cur_dep(w,dep);
			printf("%lld\n",query(w,dep));
		}
	}
	return 0;
}