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;
const int N = 200050;
int n, q;
struct Node {
  int a, w, v;
} c[N];
int kth[N], rk[N];
struct SGT {
  static const int N = ::N << 2;
  int l[N], r[N];
  long long sumval[N], sumweight[N];
  void pushup(int x) {
    sumval[x] = sumval[(x << 1)] + sumval[(x << 1 | 1)];
    sumweight[x] = sumweight[(x << 1)] + sumweight[(x << 1 | 1)];
  }
  void build(int x, int li, int ri) {
    l[x] = li, r[x] = ri;
    if (li == ri) {
      sumval[x] = 1ll * c[kth[li]].a * c[kth[li]].v,
      sumweight[x] = 1ll * c[kth[li]].a * c[kth[li]].w;
      return;
    }
    int mid = (li + ri) >> 1;
    build((x << 1), li, mid), build((x << 1 | 1), mid + 1, ri);
    pushup(x);
  }
  void modify(int x, int pos, int d) {
    if (l[x] == r[x]) {
      sumval[x] += 1ll * d * c[kth[pos]].v;
      sumweight[x] += 1ll * d * c[kth[pos]].w;
      return;
    }
    if (r[(x << 1)] >= pos)
      modify((x << 1), pos, d);
    else
      modify((x << 1 | 1), pos, d);
    pushup(x);
  }
  long long query(int x, long long sum) {
    if (l[x] == r[x]) {
      if (sumweight[x] <= sum)
        return sumval[x];
      else
        return sum / c[kth[l[x]]].w * c[kth[l[x]]].v;
    }
    if (sumweight[(x << 1)] >= sum)
      return query((x << 1), sum);
    else
      return sumval[(x << 1)] + query((x << 1 | 1), sum - sumweight[(x << 1)]);
  }
} t;
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++)
    scanf("%d%d%d", &c[i].a, &c[i].w, &c[i].v), kth[i] = i;
  sort(kth + 1, kth + n + 1, [&](const int &a, const int &b) {
    if (c[a].v != c[b].v)
      return c[a].v > c[b].v;
    else if (c[a].w != c[b].w)
      return c[a].w < c[b].w;
    return a < b;
  });
  for (int i = 1; i <= n; i++) rk[kth[i]] = i;
  t.build(1, 1, n);
  for (int i = 1; i <= q; i++) {
    int opt;
    long long x, y;
    scanf("%d%lld", &opt, &x);
    if (opt == 1)
      scanf("%lld", &y), t.modify(1, rk[y], x);
    else if (opt == 2)
      scanf("%lld", &y), t.modify(1, rk[y], -x);
    else
      printf("%lld\n", t.query(1, x));
  }
  return 0;
}
