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>
#pragma GCC optimize("O3", "Ofast", "unroll-loops")
using namespace std;
long long cnt = 1e18 + 1e17;
const long long maxn = 2e5 + 5;
pair<pair<long long, long long>, long long> u[maxn];
long long sp[maxn][20];
pair<long long, long long> t[4 * maxn];
long long num[maxn][20];
long long d2[maxn];
long long d[4 * maxn];
bool cmp(pair<pair<long long, long long>, long long> u,
         pair<pair<long long, long long>, long long> v) {
  if (u.first.first > v.first.first)
    return true;
  else if (u.first.first < v.first.first)
    return false;
  return u.first.second < v.first.second;
}
pair<long long, long long> operator+(pair<long long, long long> a,
                                     pair<long long, long long> b) {
  a.first += b.first;
  a.second += b.second;
  return a;
}
void buildnum(long long node, long long tl, long long tr) {
  num[tl][d2[tr - tl]] = node;
  if ((tr - tl) == 1) return;
  long long tm = (tl + tr) / 2;
  buildnum(2 * node + 1, tl, tm);
  buildnum(2 * node + 2, tm, tr);
}
void to(long long node, long long tl, long long tr, long long pos,
        pair<long long, long long> h) {
  if (tl > pos || tr <= pos) {
    return;
  }
  t[node].first += h.first;
  t[node].second += h.second;
  if ((tr - tl) == 1) {
    return;
  }
  long long tm = (tl + tr) / 2;
  to(2 * node + 1, tl, tm, pos, h);
  to(2 * node + 2, tm, tr, pos, h);
}
void build2() {
  for (long long j = 0; j < 20; ++j) {
    for (long long i = 0; i < maxn - (1 << j); ++i) {
      if (j == 0) {
        sp[i][j] = u[i].first.second;
        continue;
      }
      sp[i][j] = min(sp[i][j - 1], sp[i + (1 << (j - 1))][j - 1]);
    }
  }
}
pair<long long, long long> get(long long node, long long tl, long long tr,
                               long long l, long long r) {
  if (tl >= l && tr <= r) {
    return t[node];
  }
  if (tl >= r || tr <= l) {
    return {0, 0};
  }
  long long tm = (tl + tr) / 2;
  return get(2 * node + 1, tl, tm, l, r) + get(2 * node + 2, tm, tr, l, r);
}
long long mi2(long long l, long long r) {
  long long sz = 0;
  while ((1 << sz) <= (r - l)) ++sz;
  sz--;
  return min(sp[l][sz], sp[r - (1 << sz)][sz]);
}
long long n;
long long f(long long l1, long long w) {
  if (l1 >= n) return 0;
  if (u[l1].first.second > w) {
    long long low = l1;
    long long up = n;
    while (true) {
      if ((up - low) == 1) break;
      long long mid = (low + up) / 2;
      long long l2 = mi2(l1, mid + 1);
      if (l2 > w)
        low = mid;
      else
        up = mid;
    }
    return f(up, w);
  }
  long long low = 0;
  long long sumlow = 0;
  long long up = maxn;
  while (true) {
    if ((up - low) == 1) break;
    long long mid = (low + up) / 2;
    if (mid >= (n + 1)) {
      up = mid;
      continue;
    }
    if (mid < l1) {
      low = mid;
      continue;
    }
    long long w1 =
        get(num[low][d2[up - low]], low, up, max(low, l1), mid).second;
    w1 += sumlow;
    if (w1 > w)
      up = mid;
    else {
      sumlow = w1;
      low = mid;
    }
  }
  long long res1 = get(0, 0, maxn, l1, low).second;
  long long res2 = get(0, 0, maxn, l1, low).first;
  long long h = (w - res1);
  long long cnt2;
  if (low == n)
    cnt2 = 0;
  else
    cnt2 = (h / u[low].first.second) * u[low].first.first;
  if (low == n) return (res2 + cnt2);
  return (res2 + cnt2 + f(low + 1, h % u[low].first.second));
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (long long i = 1; i < maxn; ++i) d2[i] = ceil(log2(i));
  buildnum(0, 0, maxn);
  for (long long i = 0; i < 4 * maxn; ++i) t[i] = {0, 0};
  long long q;
  cin >> n >> q;
  long long a[n];
  long long z[n];
  long long b[n];
  for (long long i = 0; i < n; ++i) {
    cin >> a[i] >> u[i].first.second >> u[i].first.first;
    u[i].second = i;
  }
  sort(u, u + n, cmp);
  for (long long i = 0; i < n; ++i) z[u[i].second] = i;
  for (long long i = 0; i < n; ++i) {
    to(0, 0, maxn, i,
       {a[u[i].second] * u[i].first.first, a[u[i].second] * u[i].first.second});
    b[i] = a[u[i].second];
  }
  build2();
  while (q--) {
    long long typ;
    cin >> typ;
    if (typ == 1) {
      long long k, d;
      cin >> k >> d;
      d--;
      long long o = z[d];
      to(0, 0, maxn, o, {k * u[o].first.first, k * u[o].first.second});
      b[o] += k;
    }
    if (typ == 2) {
      long long k, d;
      cin >> k >> d;
      d--;
      long long o = z[d];
      to(0, 0, maxn, o, {-k * u[o].first.first, -k * u[o].first.second});
      b[o] -= k;
    }
    if (typ == 3) {
      long long w;
      cin >> w;
      cout << f(0, w) << endl;
    }
  }
  return 0;
}
