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<bits/stdc++.h>
using namespace std;

typedef long long LL;

const int N=200000,C=53;
const LL INF=(1LL<<53)-1;

int n,cq,pos[N+9];
struct thing{
  LL cnt,w,v;
  int id;
}a[N+9];

bool cmp(const thing &a,const thing &b){return a.v>b.v||a.v==b.v&&a.w<b.w;}

void into(){
  scanf("%d%d",&n,&cq);
  for (int i=1;i<=n;++i){
	scanf("%lld%lld%lld",&a[i].cnt,&a[i].w,&a[i].v);
	a[i].id=i;
  }
  sort(a+1,a+n+1,cmp);
  for (int i=1;i<=n;++i) pos[a[i].id]=i;
}

struct tree{
  LL cnt,w[C],v[C],mn[C];
}tr[N*4+9];

void Pushup(int k){
  int ls=k<<1,rs=k<<1|1;
  for (int i=0;i<C;++i){
	tr[k].w[i]=tr[ls].w[i]+tr[rs].w[i];
	tr[k].v[i]=tr[ls].v[i]+tr[rs].v[i];
	tr[k].mn[i]=min(tr[ls].mn[i],tr[ls].w[i]+tr[rs].mn[i]);
  }
}

void Build(int l,int r,int k){
  if (l==r){
	tr[k].cnt=a[l].cnt;
	for (int i=0;i<C;++i)
	  if (a[l].w<1LL<<i){
		tr[k].w[i]=tr[k].cnt*a[l].w;
		tr[k].v[i]=tr[k].cnt*a[l].v;
		tr[k].mn[i]=INF;
	  }else{
		tr[k].w[i]=tr[k].v[i]=0;
		tr[k].mn[i]=tr[k].cnt?a[l].w:INF;
	  }
	return;
  }
  int mid=l+r>>1;
  Build(l,mid,k<<1);
  Build(mid+1,r,k<<1|1);
  Pushup(k);
}

void Change_add(int p,LL v,int l,int r,int k){
  if (l==r){
	tr[k].cnt+=v;
	for (int i=0;i<C;++i)
	  if (a[l].w<1LL<<i){
		tr[k].w[i]=tr[k].cnt*a[l].w;
		tr[k].v[i]=tr[k].cnt*a[l].v;
		tr[k].mn[i]=INF;
	  }else{
		tr[k].w[i]=tr[k].v[i]=0;
		tr[k].mn[i]=tr[k].cnt?a[l].w:INF;
	  }
	return;
  }
  int mid=l+r>>1;
  p<=mid?Change_add(p,v,l,mid,k<<1):Change_add(p,v,mid+1,r,k<<1|1);
  Pushup(k);
}

LL lim,ans;

int Query_nxt0(int id,int l,int r,int k){
  if (l==r) return l;
  int mid=l+r>>1,y=k<<1;
  if (tr[y].mn[id]<=lim) return Query_nxt0(id,l,mid,y);
  else{
	ans+=tr[y].v[id];
	lim-=tr[y].w[id];
	return Query_nxt0(id,mid+1,r,k<<1|1);
  }
}

int Query_nxt1(int id,int l,int r,int k){
  if (l==r) return l;
  int mid=l+r>>1,y=k<<1;
  if (tr[y].w[id]<=lim){
	ans+=tr[y].v[id];
	lim-=tr[y].w[id];
	return Query_nxt1(id,mid+1,r,k<<1|1);
  }else return Query_nxt1(id,l,mid,y);
}

int Query_nxt(int id,int p,int l,int r,int k){
  if (l==r) return n+1;
  int mid=l+r>>1,res;
  if (p<=mid){
	if ((res=Query_nxt(id,p,l,mid,k<<1))<=n) return res;
	int y=k<<1|1;
	if (tr[y].mn[id]<=lim) return Query_nxt0(id,mid+1,r,y);
	else if (tr[y].w[id]>lim) return Query_nxt1(id,mid+1,r,y);
	  else ans+=tr[y].v[id],lim-=tr[y].w[id];
  }else res=Query_nxt(id,p,mid+1,r,k<<1|1);
  return res;
}

void work(){
  Build(0,n,1);
}

void outo(){
  for (;cq--;){
	int opt;
	scanf("%d",&opt);
	if (opt<=2){
	  int k,p;
	  scanf("%d%d",&k,&p);
	  p=pos[p];k=opt==1?k:-k;
	  a[p].cnt+=k;
	  Change_add(p,k,0,n,1);
	}else{
	  scanf("%lld",&lim);
	  if (lim>=INF) lim=INF-1;
	  ans=0;
	  for (int i=C-1,p=0;i>=0;--i){
		if (lim<1LL<<i) continue;
		p=Query_nxt(i,p,0,n,1);
		if (p>n) break;
		LL c=lim/a[p].w;
		ans+=c*a[p].v;
		lim-=c*a[p].w;
	  }
	  printf("%lld\n",ans);
	}
  }
}

int main(){
  into();
  work();
  outo();
  return 0;
}