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;
template <class T>
bool chmin(T &x, const T &y) {
  return x > y ? (x = y, true) : false;
}
template <class T>
bool chmax(T &x, const T &y) {
  return x < y ? (x = y, true) : false;
}
int n, q, cnt[200005], newId[200005];
struct Item {
  int w, v, id;
  bool operator<(const Item &b) const {
    if (v == b.v) return w < b.w;
    return v > b.v;
  }
} a[200005];
long long wbit[200005], vbit[200005];
void add(long long *bit, int pos, long long x) {
  for (int i = pos; i <= n; i += i & -i) {
    bit[i] += x;
  }
}
long long qsum(long long *bit, int pos) {
  long long res = 0;
  for (int i = pos; i; i -= i & -i) {
    res += bit[i];
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", cnt + i, &a[i].w, &a[i].v);
    a[i].id = i;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    newId[a[i].id] = i;
    add(wbit, i, (long long)cnt[a[i].id] * a[i].w);
    add(vbit, i, (long long)cnt[a[i].id] * a[i].v);
  }
  for (int i = 1; i <= q; i++) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int k, d;
      scanf("%d%d", &k, &d);
      add(wbit, newId[d], (long long)k * a[newId[d]].w);
      add(vbit, newId[d], (long long)k * a[newId[d]].v);
    } else if (t == 2) {
      int k, d;
      scanf("%d%d", &k, &d);
      add(wbit, newId[d], -(long long)k * a[newId[d]].w);
      add(vbit, newId[d], -(long long)k * a[newId[d]].v);
    } else {
      long long c;
      scanf("%lld", &c);
      int lb = 0, rb = n;
      while (lb < rb) {
        int mid = (lb + rb + 1) / 2;
        if (qsum(wbit, mid) <= c)
          lb = mid;
        else
          rb = mid - 1;
      }
      long long ans = qsum(vbit, lb);
      if (lb < n) ans += (c - qsum(wbit, lb)) / a[lb + 1].w * a[lb + 1].v;
      printf("%lld\n", ans);
    }
  }
  return 0;
}
