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 maxn = 2e5 + 5;
int n, q, ord[maxn], inv[maxn];
long long a[maxn], weight[maxn], val[maxn];
bool Less1(int x, int y) {
  if (val[x] != val[y]) return val[x] > val[y];
  return weight[x] < weight[y];
}
struct node {
  int l, r;
  long long w;
} tree[4 * maxn];
void push_up(int cur) {
  tree[cur].w = tree[cur << 1].w + tree[cur << 1 | 1].w;
  return;
}
void build(int l, int r, int cur) {
  tree[cur].l = l;
  tree[cur].r = r;
  if (l == r) {
    tree[cur].w = weight[ord[l]] * a[ord[l]];
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, cur << 1);
  build(mid + 1, r, cur << 1 | 1);
  push_up(cur);
  return;
}
void upd(int pos, int cur) {
  if (pos == tree[cur].l && tree[cur].r == pos) {
    tree[cur].w = weight[ord[pos]] * a[ord[pos]];
    return;
  }
  if (tree[cur].l > pos || tree[cur].r < pos) return;
  upd(pos, cur << 1);
  upd(pos, cur << 1 | 1);
  push_up(cur);
  return;
}
pair<long long, int> query(long long c, int cur) {
  if (tree[cur].l == tree[cur].r) return make_pair(c, tree[cur].l);
  if (c > tree[cur << 1].w)
    return query(c - tree[cur << 1].w, cur << 1 | 1);
  else
    return query(c, cur << 1);
}
long long v[maxn];
void add(int pos, long long delta) {
  while (pos <= n) {
    v[pos] += delta;
    pos += pos & (-pos);
  }
  return;
}
long long ask(int pos) {
  long long ret = 0;
  while (pos) {
    ret += v[pos];
    pos -= pos & (-pos);
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld%lld", &a[i], &weight[i], &val[i]);
    ord[i] = i;
  }
  sort(ord + 1, ord + n + 1, Less1);
  for (int i = 1; i <= n; i++) inv[ord[i]] = i;
  build(1, n, 1);
  for (int i = 1; i <= n; i++) add(i, val[ord[i]] * a[ord[i]]);
  while (q--) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      int k, d;
      scanf("%d%d", &k, &d);
      a[d] += k;
      upd(inv[d], 1);
      add(inv[d], k * val[d]);
    } else if (op == 2) {
      int k, d;
      scanf("%d%d", &k, &d);
      a[d] -= k;
      upd(inv[d], 1);
      add(inv[d], -k * val[d]);
    } else {
      long long c;
      scanf("%lld", &c);
      pair<long long, int> whole = query(c, 1);
      long long tot = ask(whole.second - 1);
      tot +=
          min(whole.first / weight[ord[whole.second]], a[ord[whole.second]]) *
          val[ord[whole.second]];
      printf("%lld\n", tot);
    }
  }
  return 0;
}
