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("Ofast")
using namespace std;
template <class T>
struct cLtraits_identity {
  using type = T;
};
template <class T>
using cLtraits_try_make_signed =
    typename conditional<is_integral<T>::value, make_signed<T>,
                         cLtraits_identity<T> >::type;
template <class S, class T>
struct cLtraits_common_type {
  using tS = typename cLtraits_try_make_signed<S>::type;
  using tT = typename cLtraits_try_make_signed<T>::type;
  using type = typename common_type<tS, tT>::type;
};
void *wmem;
char memarr[524288000];
template <class S, class T>
inline auto min_L(S a, T b) -> typename cLtraits_common_type<S, T>::type {
  return (typename cLtraits_common_type<S, T>::type)a <=
                 (typename cLtraits_common_type<S, T>::type)b
             ? a
             : b;
}
template <class T>
inline void walloc1d(T **arr, int x, void **mem = &wmem) {
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void *)(((char *)(*mem)) + skip[((unsigned long long)(*mem)) & 15]);
  (*arr) = (T *)(*mem);
  (*mem) = ((*arr) + x);
}
template <class T>
inline void walloc1d(T **arr, int x1, int x2, void **mem = &wmem) {
  walloc1d(arr, x2 - x1, mem);
  (*arr) -= x1;
}
template <class T1, class T2, class T3>
void sortA_L(int N, T1 a[], T2 b[], T3 c[], void *mem = wmem) {
  int i;
  pair<T1, pair<T2, T3> > *arr;
  walloc1d(&arr, N, &mem);
  for (i = (0); i < (N); i++) {
    arr[i].first = a[i];
    arr[i].second.first = b[i];
    arr[i].second.second = c[i];
  }
  sort(arr, arr + N);
  for (i = (0); i < (N); i++) {
    a[i] = arr[i].first;
    b[i] = arr[i].second.first;
    c[i] = arr[i].second.second;
  }
}
template <class T1, class T2, class T3, class T4>
void sortA_L(int N, T1 a[], T2 b[], T3 c[], T4 d[], void *mem = wmem) {
  int i;
  pair<pair<T1, T2>, pair<T3, T4> > *arr;
  walloc1d(&arr, N, &mem);
  for (i = (0); i < (N); i++) {
    arr[i].first.first = a[i];
    arr[i].first.second = b[i];
    arr[i].second.first = c[i];
    arr[i].second.second = d[i];
  }
  sort(arr, arr + N);
  for (i = (0); i < (N); i++) {
    a[i] = arr[i].first.first;
    b[i] = arr[i].first.second;
    c[i] = arr[i].second.first;
    d[i] = arr[i].second.second;
  }
}
inline int my_getchar() {
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if (s == e && e == 1048576) {
    e = fread(buf, 1, 1048576, stdin);
    s = 0;
  }
  if (s == e) {
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x) {
  int k;
  int m = 0;
  x = 0;
  for (;;) {
    k = my_getchar();
    if (k == '-') {
      m = 1;
      break;
    }
    if ('0' <= k && k <= '9') {
      x = k - '0';
      break;
    }
  }
  for (;;) {
    k = my_getchar();
    if (k < '0' || k > '9') {
      break;
    }
    x = x * 10 + k - '0';
  }
  if (m) {
    x = -x;
  }
}
inline void rd(long long &x) {
  int k;
  int m = 0;
  x = 0;
  for (;;) {
    k = my_getchar();
    if (k == '-') {
      m = 1;
      break;
    }
    if ('0' <= k && k <= '9') {
      x = k - '0';
      break;
    }
  }
  for (;;) {
    k = my_getchar();
    if (k < '0' || k > '9') {
      break;
    }
    x = x * 10 + k - '0';
  }
  if (m) {
    x = -x;
  }
}
struct MY_WRITER {
  char buf[1048576];
  int s;
  int e;
  MY_WRITER() {
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER() {
    if (s) {
      fwrite(buf, 1, s, stdout);
    }
  }
};
MY_WRITER MY_WRITER_VAR;
void my_putchar(int a) {
  if (MY_WRITER_VAR.s == MY_WRITER_VAR.e) {
    fwrite(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a) { my_putchar(a); }
inline void wt_L(long long x) {
  int s = 0;
  int m = 0;
  char f[20];
  if (x < 0) {
    m = 1;
    x = -x;
  }
  while (x) {
    f[s++] = x % 10;
    x /= 10;
  }
  if (!s) {
    f[s++] = 0;
  }
  if (m) {
    my_putchar('-');
  }
  while (s--) {
    my_putchar(f[s] + '0');
  }
}
template <class T>
struct fenwick {
  int size;
  int memory;
  T *data;
  void malloc(int mem);
  void malloc(int mem, int fg);
  void walloc(int mem, void **workMemory = &wmem);
  void walloc(int mem, int fg, void **workMemory = &wmem);
  void free(void);
  void init(int N);
  void add(int k, T val);
  T get(int k);
  T range(int a, int b);
  int kth(T k);
};
template <class SVAL, class SFUN>
struct segtree_rh {
  int N;
  int logN;
  int trueN;
  SVAL *val;
  SFUN *fun;
  char *dofun;
  void malloc(int maxN, int once = 0);
  void walloc(int maxN, int once = 0, void **mem = &wmem);
  void free(void);
  SVAL &operator[](int i);
  void setN(int n, int zerofill = 1, int dobuild = 1);
  void build(void);
  inline void push_one(int a);
  inline void push(int a);
  inline void build(int a);
  inline void change(int a, int b, SFUN f);
  inline SVAL get(int a, int b);
  template <bool (*f)(SVAL)>
  int max_right(int a, int mx);
  template <bool (*f)(SVAL)>
  int max_right(int a);
  template <bool (*f)(SVAL)>
  int min_left(int b, int mn);
  template <bool (*f)(SVAL)>
  int min_left(int b);
};
int N;
int Q;
long long A[200000];
long long W[200000];
long long V[200000];
int ind[200000];
int rev[200000];
int T;
int K;
int D;
long long C;
struct sval {
  long long sz;
  long long sm;
};
struct sfun {
  long long a;
};
sval segtree_rh_merge(sval a, sval b) { return {a.sz + b.sz, a.sm + b.sm}; }
sval segtree_rh_apply(sfun f, sval a) { return {a.sz, a.sm + f.a * a.sz}; }
sfun segtree_rh_compose(sfun f, sfun g) { return {f.a + g.a}; }
long long segtree_rh_apply(long long f, long long a) { return f; }
long long segtree_rh_merge(long long a, long long b) { return min_L(a, b); }
long long segtree_rh_compose(long long f, long long g) { return f; }
segtree_rh<sval, sfun> tw[20];
fenwick<long long> tv[20];
segtree_rh<long long, long long> tn[20];
bool f(sval a) { return a.sm <= C; }
bool g(long long a) { return a > C; }
int main() {
  int AlM5nNnR, i, k;
  wmem = memarr;
  rd(N);
  rd(Q);
  {
    int KL2GvlyY;
    for (KL2GvlyY = (0); KL2GvlyY < (N); KL2GvlyY++) {
      rd(A[KL2GvlyY]);
      rd(W[KL2GvlyY]);
      rd(V[KL2GvlyY]);
    }
  }
  for (i = (0); i < (N); i++) {
    ind[i] = i;
  }
  for (i = (0); i < (N); i++) {
    V[i] = -V[i];
  }
  sortA_L(N, V, W, A, ind);
  for (i = (0); i < (N); i++) {
    V[i] = -V[i];
  }
  for (i = (0); i < (N); i++) {
    rev[ind[i]] = i;
  }
  for (k = (0); k < (20); k++) {
    tv[k].walloc(N, 1);
    for (i = (0); i < (N); i++) {
      if (W[i] <= (1 << k)) {
        tv[k].add(i, A[i] * V[i]);
      }
    }
    tw[k].walloc(N);
    tw[k].setN(N);
    for (i = (0); i < (N); i++) {
      tw[k][i] = {0LL, 0LL};
      if (W[i] <= (1 << k)) {
        tw[k][i] = {1LL, A[i] * W[i]};
      }
    }
    tw[k].build();
    tn[k].walloc(N);
    tn[k].setN(N);
    for (i = (0); i < (N); i++) {
      tn[k][i] = 4611686016279904256LL;
    }
    for (i = (0); i < (N); i++) {
      if (W[i] <= (1 << k) && A[i]) {
        tn[k][i] = W[i];
      }
    }
    tn[k].build();
  }
  for (AlM5nNnR = (0); AlM5nNnR < (Q); AlM5nNnR++) {
    rd(T);
    if (T == 1 || T == 2) {
      rd(K);
      rd(D);
      D += (-1);
      D = rev[D];
      if (T == 2) {
        K *= -1;
      }
      A[D] += K;
      for (k = (0); k < (20); k++) {
        if (W[D] <= (1 << k)) {
          tv[k].add(D, V[D] * K);
          tw[k].change(D, D + 1, {W[D] * K});
          if (A[D]) {
            tn[k].change(D, D + 1, W[D]);
          } else {
            tn[k].change(D, D + 1, 4611686016279904256LL);
          }
        }
      }
    }
    if (T == 3) {
      int st = 0;
      int nx;
      int k = 19;
      long long res = 0;
      long long mx;
      rd(C);
      while (st < N) {
        while (k && (1 << k) > C) {
          k--;
        }
        nx = tw[k].max_right<f>(st);
        if (st < nx) {
          res += tv[k].range(st, nx - 1);
          C -= tw[k].get(st, nx).sm;
          st = nx;
        }
        if (st == N) {
          break;
        }
        st = tn[k].max_right<g>(st);
        if (st == N) {
          break;
        }
        mx = min_L(A[st], C / W[st]);
        res += V[st] * mx;
        C -= W[st] * mx;
        st++;
      }
      wt_L(res);
      wt_L('\n');
    }
  }
  return 0;
}
template <class T>
void fenwick<T>::malloc(int mem) {
  memory = mem;
  data = (T *)std::malloc(sizeof(T) * mem);
}
template <class T>
void fenwick<T>::malloc(int mem, int fg) {
  memory = mem;
  data = (T *)std::malloc(sizeof(T) * mem);
  if (fg) {
    init(mem);
  }
}
template <class T>
void fenwick<T>::walloc(int mem, void **workMemory) {
  memory = mem;
  walloc1d(&data, mem, workMemory);
}
template <class T>
void fenwick<T>::walloc(int mem, int fg, void **workMemory) {
  memory = mem;
  walloc1d(&data, mem, workMemory);
  if (fg) {
    init(mem);
  }
}
template <class T>
void fenwick<T>::free(void) {
  memory = 0;
  free(data);
}
template <class T>
void fenwick<T>::init(int N) {
  size = N;
  memset(data, 0, sizeof(T) * N);
}
template <class T>
void fenwick<T>::add(int k, T val) {
  while (k < size) {
    data[k] += val;
    k |= k + 1;
  }
}
template <class T>
T fenwick<T>::get(int k) {
  T res = 0;
  while (k >= 0) {
    res += data[k];
    k = (k & (k + 1)) - 1;
  }
  return res;
}
template <class T>
T fenwick<T>::range(int a, int b) {
  if (b == -1) {
    b = size - 1;
  }
  return get(b) - get(a - 1);
}
template <class T>
int fenwick<T>::kth(T k) {
  int i = 0;
  int j = size;
  int c;
  T v;
  while (i < j) {
    c = (i + j) / 2;
    v = get(c);
    if (v <= k) {
      i = c + 1;
    } else {
      j = c;
    }
  }
  return i == size ? -1 : i;
}
template <class SVAL, class SFUN>
void segtree_rh<SVAL, SFUN>::malloc(int maxN, int once) {
  int i;
  for (i = 1; i < maxN; i *= 2) {
    ;
  }
  val = new SVAL[2 * i];
  fun = new SFUN[i];
  dofun = new char[i];
  if (once) {
    setN(maxN);
  }
}
template <class SVAL, class SFUN>
void segtree_rh<SVAL, SFUN>::walloc(int maxN, int once, void **mem) {
  int i;
  for (i = 1; i < maxN; i *= 2) {
    ;
  }
  walloc1d(&val, 2 * i, mem);
  walloc1d(&fun, i, mem);
  walloc1d(&dofun, i, mem);
  if (once) {
    setN(maxN);
  }
}
template <class SVAL, class SFUN>
void segtree_rh<SVAL, SFUN>::free(void) {
  delete[] val;
  delete[] fun;
}
template <class SVAL, class SFUN>
SVAL &segtree_rh<SVAL, SFUN>::operator[](int i) {
  return val[N + i];
}
template <class SVAL, class SFUN>
void segtree_rh<SVAL, SFUN>::setN(int n, int zerofill, int dobuild) {
  int i;
  for (i = 1, logN = 0; i < n; i *= 2, logN++) {
    ;
  }
  trueN = n;
  N = i;
  if (dobuild) {
    build();
  }
}
template <class SVAL, class SFUN>
void segtree_rh<SVAL, SFUN>::build(void) {
  int i;
  for (i = N - 1; i; i--) {
    val[i] = segtree_rh_merge(val[2 * i], val[2 * i + 1]);
  }
  int Wv3_QJ0O = N;
  for (i = (1); i < (Wv3_QJ0O); i++) {
    dofun[i] = 0;
  }
}
template <class SVAL, class SFUN>
inline void segtree_rh<SVAL, SFUN>::push_one(int a) {
  if (dofun[a]) {
    if (2 * a < N) {
      if (dofun[2 * a]) {
        fun[2 * a] = segtree_rh_compose(fun[a], fun[2 * a]);
      } else {
        fun[2 * a] = fun[a];
        dofun[2 * a] = 1;
      }
    }
    val[2 * a] = segtree_rh_apply(fun[a], val[2 * a]);
    if (2 * a + 1 < N) {
      if (dofun[2 * a + 1]) {
        fun[2 * a + 1] = segtree_rh_compose(fun[a], fun[2 * a + 1]);
      } else {
        fun[2 * a + 1] = fun[a];
        dofun[2 * a + 1] = 1;
      }
    }
    val[2 * a + 1] = segtree_rh_apply(fun[a], val[2 * a + 1]);
    dofun[a] = 0;
  }
}
template <class SVAL, class SFUN>
inline void segtree_rh<SVAL, SFUN>::push(int a) {
  int i;
  for (i = logN; i; i--) {
    push_one(a >> i);
  }
}
template <class SVAL, class SFUN>
inline void segtree_rh<SVAL, SFUN>::build(int a) {
  while (a > 1) {
    a /= 2;
    val[a] = segtree_rh_merge(val[2 * a], val[2 * a + 1]);
    if (dofun[a]) {
      val[a] = segtree_rh_apply(fun[a], val[a]);
    }
  }
}
template <class SVAL, class SFUN>
inline void segtree_rh<SVAL, SFUN>::change(int a, int b, SFUN f) {
  int aa;
  int bb;
  if (a >= b) {
    return;
  }
  aa = (a += N);
  bb = (b += N);
  push(a);
  push(b - 1);
  if (a % 2) {
    val[a] = segtree_rh_apply(f, val[a]);
    a++;
  }
  if (b % 2) {
    b--;
    val[b] = segtree_rh_apply(f, val[b]);
  }
  a /= 2;
  b /= 2;
  while (a < b) {
    if (a % 2) {
      val[a] = segtree_rh_apply(f, val[a]);
      if (dofun[a]) {
        fun[a] = segtree_rh_compose(f, fun[a]);
      } else {
        fun[a] = f;
        dofun[a] = 1;
      }
      a++;
    }
    if (b % 2) {
      b--;
      val[b] = segtree_rh_apply(f, val[b]);
      if (dofun[b]) {
        fun[b] = segtree_rh_compose(f, fun[b]);
      } else {
        fun[b] = f;
        dofun[b] = 1;
      }
    }
    a /= 2;
    b /= 2;
  }
  build(aa);
  build(bb - 1);
}
template <class SVAL, class SFUN>
inline SVAL segtree_rh<SVAL, SFUN>::get(int a, int b) {
  SVAL res;
  SVAL tmp;
  int fga = 0;
  int fgb = 0;
  a += N;
  b += N;
  push(a);
  push(b - 1);
  while (a < b) {
    if (a % 2) {
      if (fga) {
        res = segtree_rh_merge(res, val[a]);
      } else {
        res = val[a];
        fga = 1;
      }
      a++;
    }
    if (b % 2) {
      b--;
      if (fgb) {
        tmp = segtree_rh_merge(val[b], tmp);
      } else {
        tmp = val[b];
        fgb = 1;
      }
    }
    a /= 2;
    b /= 2;
  }
  if (fga == 1 && fgb == 0) {
    return res;
  }
  if (fga == 0 && fgb == 1) {
    return tmp;
  }
  if (fga == 1 && fgb == 1) {
    return segtree_rh_merge(res, tmp);
  }
  return res;
}
template <class SVAL, class SFUN>
template <bool (*f)(SVAL)>
int segtree_rh<SVAL, SFUN>::max_right(int a, int mx) {
  int fg = 0;
  int ta = a;
  int sz = 1;
  SVAL cur;
  SVAL tmp;
  if (a >= mx) {
    return mx;
  }
  a += N;
  push(a);
  for (;;) {
    while (a % 2 == 0) {
      a /= 2;
      sz *= 2;
    }
    if (ta + sz <= mx) {
      if (fg == 0) {
        tmp = val[a];
      } else {
        tmp = segtree_rh_merge(cur, val[a]);
      }
    }
    if (ta + sz > mx || !f(tmp)) {
      while (a < N) {
        push_one(a);
        a *= 2;
        sz /= 2;
        if (ta + sz <= mx) {
          if (fg == 0) {
            tmp = val[a];
          } else {
            tmp = segtree_rh_merge(cur, val[a]);
          }
        }
        if (ta + sz <= mx && f(tmp)) {
          fg = 1;
          cur = tmp;
          a++;
          ta += sz;
        }
      }
      return a - N;
    }
    fg = 1;
    cur = tmp;
    if ((a & (a + 1)) == 0) {
      break;
    }
    a++;
    ta += sz;
  }
  return mx;
}
template <class SVAL, class SFUN>
template <bool (*f)(SVAL)>
int segtree_rh<SVAL, SFUN>::max_right(int a) {
  return max_right<f>(a, trueN);
}
template <class SVAL, class SFUN>
template <bool (*f)(SVAL)>
int segtree_rh<SVAL, SFUN>::min_left(int b, int mn) {
  int fg = 0;
  int tb = b;
  int sz = 1;
  SVAL cur;
  SVAL tmp;
  if (b <= mn) {
    return mn;
  }
  b += N;
  push(b - 1);
  for (;;) {
    while (b % 2 == 0) {
      b /= 2;
      sz *= 2;
    }
    if (tb - sz >= mn) {
      if (fg == 0) {
        tmp = val[b - 1];
      } else {
        tmp = segtree_rh_merge(val[b - 1], cur);
      }
    }
    if (tb - sz < mn || !f(tmp)) {
      while (b - 1 < N) {
        push_one(b - 1);
        b *= 2;
        sz /= 2;
        if (tb - sz >= mn) {
          if (fg == 0) {
            tmp = val[b - 1];
          } else {
            tmp = segtree_rh_merge(val[b - 1], cur);
          }
        }
        if (tb - sz >= mn && f(tmp)) {
          fg = 1;
          cur = tmp;
          b--;
          tb -= sz;
        }
      }
      return b - N;
    }
    fg = 1;
    cur = tmp;
    b--;
    tb -= sz;
    if (tb <= mn) {
      break;
    }
  }
  return mn;
}
template <class SVAL, class SFUN>
template <bool (*f)(SVAL)>
int segtree_rh<SVAL, SFUN>::min_left(int b) {
  return min_left<f>(b, 0);
}
