2 8
2 15 400
1 13 100
3 26
3 27
3 28
3 29
3 30
3 31
3 32
3 33
 3 8
2 15 400
1 1 200
1 13 100
3 26
3 27
3 28
3 29
3 30
3 31
3 32
3 33

400
400
500
500
800
800
800
800
 600
600
600
700
800
1000
1000
1000

#include <bits/stdc++.h>
using namespace std;
long long wsum[1000010], vsum[1000010], v[1000010], w[1000010], real1[1000010];
struct node {
  long long w, v, d, i;
} a[1000010];
void pushup(long long num) {
  wsum[num] = wsum[num * 2] + wsum[num * 2 + 1];
  vsum[num] = vsum[num * 2] + vsum[num * 2 + 1];
}
void build(long long num, long long r, long long l) {
  if (r == l) {
    w[num] = a[r].w;
    v[num] = a[r].v;
    wsum[num] = a[r].w * a[r].d;
    vsum[num] = a[r].v * a[r].d;
    return;
  }
  long long mid = (r + l) / 2;
  build(num * 2, r, mid);
  build(num * 2 + 1, mid + 1, l);
  pushup(num);
}
void update(long long num, long long r, long long l, long long x, long long y) {
  if (r == l) {
    wsum[num] += w[num] * y;
    vsum[num] += v[num] * y;
    return;
  }
  long long mid = (r + l) / 2;
  if (x <= mid)
    update(num * 2, r, mid, x, y);
  else
    update(num * 2 + 1, mid + 1, l, x, y);
  pushup(num);
}
long long cmp(node a, node b) { return a.v > b.v || (a.v == b.v && a.w < b.w); }
long long find(long long num, long long r, long long l, long long c) {
  if (r == l) return min((c / w[num]) * v[num], vsum[num]);
  long long mid = (r + l) / 2;
  if (c <= wsum[num * 2]) return find(num * 2, r, mid, c);
  return find(num * 2 + 1, mid + 1, l, c - wsum[num * 2]) + vsum[num * 2];
}
signed main() {
  long long n, q, i, type, k, d, c;
  scanf("%lld%lld", &n, &q);
  for (i = 1; i <= n; i++) {
    scanf("%lld%lld%lld", &a[i].d, &a[i].w, &a[i].v);
    a[i].i = i;
  }
  sort(a + 1, a + n + 1, cmp);
  for (i = 1; i <= n; i++) real1[a[i].i] = i;
  build(1, 1, n);
  while (q--) {
    scanf("%lld", &type);
    if (type == 1 || type == 2) {
      scanf("%lld%lld", &k, &d);
      d = real1[d];
      if (type == 2) k = -k;
      update(1, 1, n, d, k);
    }
    if (type == 3) {
      scanf("%lld", &c);
      printf("%lld\n", find(1, 1, n, c));
    }
  }
}
