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;
class node {
 public:
  int w, v, q;
  node() {
    w = v = 0;
    q = -1;
  }
  node &operator=(const node &t) {
    w = t.w;
    v = t.v;
    q = t.q;
    return *this;
  }
  node &operator=(const array<int, 4> t) {
    w = t[1];
    v = t[2];
    q = t[0];
    return *this;
  }
};
const int N = 400005;
node tree[N];
void print(int siz) {
  for (int i = 1; i < (siz * 2); i++) {
    cout << tree[i].v << " : " << tree[i].w << " : " << tree[i].q << '\n';
  }
}
void update(node a, int ind) {
  node prev = tree[ind];
  tree[ind] = a;
  ind /= 2;
  while (ind > 0) {
    tree[ind].v -= (prev.v * prev.q);
    tree[ind].v += (a.v * a.q);
    tree[ind].w -= (prev.w * prev.q);
    tree[ind].w += (a.w * a.q);
    ind /= 2;
  }
}
void query(int l, int r, int ind, int &left, int &res) {
  if (left >= tree[ind].w) {
    if (tree[ind].q == -1) {
      res += tree[ind].v;
      left -= tree[ind].w;
    } else {
      int quan = min(tree[ind].q, (left / tree[ind].w));
      res += (quan * tree[ind].v);
      left -= quan * tree[ind].w;
    }
  } else {
    int mid = (l + r) / 2;
    if ((tree[ind * 2].q == -1 && tree[ind * 2].w >= left) ||
        (tree[ind * 2].q != -1 && (left <= tree[ind * 2].q * tree[ind * 2].w)))
      query(l, mid, ind * 2, left, res);
    else {
      query(l, mid, ind * 2, left, res);
      query(mid + 1, r, ind * 2 + 1, left, res);
    }
  }
}
void solve() {
  int n, q;
  cin >> n >> q;
  int siz = 1;
  while (siz < n) {
    siz *= 2;
  }
  array<int, 4> arr[n];
  for (int i = 0; i < n; i++) {
    arr[i][3] = i + 1;
    cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
  }
  sort(arr, arr + n, [](array<int, 4> a, array<int, 4> b) {
    if (a[2] == b[2]) {
      return a[1] < b[1];
    } else {
      return a[2] > b[2];
    }
  });
  int indexMap[n + 1];
  for (int i = 0; i < n; i++) {
    indexMap[arr[i][3]] = i;
  }
  node temp;
  for (int i = 0; i < n; i++) {
    temp = arr[i];
    update(temp, siz + i);
  }
  int x, ki, di;
  while (q--) {
    cin >> x;
    if (x != 3) {
      cin >> ki >> di;
      if (x == 2) ki = -ki;
      int ind = indexMap[di];
      temp = arr[ind];
      temp.q += ki;
      arr[ind][0] = temp.q;
      update(temp, siz + ind);
    } else {
      cin >> x;
      int res = 0;
      query(1, siz, 1, x, res);
      cout << res << '\n';
    }
  }
}
int main() {
  solve();
  return 0;
}
