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 = 100010;
int n, q, k, d, a, w, v, t, indexes[MAXN];
long long c, sums[MAXN], num[MAXN];
pair<pair<int, int>, pair<int, int>> diamonds[MAXN];
bool cmp(pair<pair<int, int>, pair<int, int>> a,
         pair<pair<int, int>, pair<int, int>> b);
long long searchT3(long long c);
void printData();
int main() {
  iostream::sync_with_stdio(false);
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> a >> w >> v;
    diamonds[i].first.first = i;
    diamonds[i].first.second = a;
    diamonds[i].second.first = w;
    diamonds[i].second.second = v;
  }
  sort(diamonds, diamonds + n, cmp);
  long long sum = 0, sum2 = 0;
  for (int i = 0; i < n; i++) {
    indexes[diamonds[i].first.first] = i;
    sum += diamonds[i].first.second * diamonds[i].second.first;
    sum2 += diamonds[i].first.second * diamonds[i].second.second;
    sums[i] = sum;
    num[i] = sum2;
  }
  for (int i = 0; i < q; i++) {
    cin >> t;
    if (t == 1 || t == 2) {
      cin >> k >> d;
      if (t == 2) k *= -1;
      d = indexes[d - 1];
      diamonds[d].first.second += k;
      for (int i = d; i < n; i++) {
        sums[i] += k * diamonds[d].second.first;
        num[i] += k * diamonds[d].second.second;
      }
    }
    if (t == 3) {
      cin >> c;
      cout << searchT3(c) << "\n";
    }
  }
  return 0;
}
bool cmp(pair<pair<int, int>, pair<int, int>> a,
         pair<pair<int, int>, pair<int, int>> b) {
  if (a.second.second > b.second.second) return true;
  if (a.second.second < b.second.second) return false;
  if (a.second.first > b.second.first) return false;
  return true;
}
long long searchT3(long long c) {
  long long l = -1, r = n - 1, mid;
  if (c >= sums[n - 1]) return num[n - 1];
  while (l + 1 < r) {
    mid = (l + r) / 2;
    if (c >= sums[mid])
      l = mid;
    else
      r = mid;
  }
  if (l >= 0) c -= sums[l];
  return num[l] + c / diamonds[r].second.first * diamonds[r].second.second;
}
void printData() {
  for (int i = 0; i < n; i++) {
    cout << diamonds[i].first.first + 1 << ") " << diamonds[i].first.second
         << " " << diamonds[i].second.first << " " << diamonds[i].second.second
         << endl;
  }
  for (int i = 0; i < n; i++) {
    cout << num[i] << " ";
  }
  cout << endl;
  for (int i = 0; i < n; i++) {
    cout << sums[i] << " ";
  }
  cout << endl;
}
