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;
using vi = vector<long long>;
template <typename T>
std::istream& operator>>(std::istream& input, std::vector<T>& data) {
  for (T& first : data) input >> first;
  return input;
}
template <typename T>
std::ostream& operator<<(std::ostream& output, const pair<T, T>& data) {
  output << "(" << data.first << "," << data.second << ")";
  return output;
}
template <typename T>
std::ostream& operator<<(std::ostream& output, const std::vector<T>& data) {
  for (const T& first : data) output << first << " ";
  return output;
}
long long div_up(long long a, long long b) {
  return a / b + ((a ^ b) > 0 && a % b);
}
long long div_down(long long a, long long b) {
  return a / b - ((a ^ b) < 0 && a % b);
}
long long math_mod(long long a, long long b) { return a - b * div_down(a, b); }
template <class T>
using V = vector<T>;
template <class T>
void re(V<T>& first) {
  for (auto& a : first) cin >> a;
}
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
long long gcd(long long a, long long b) {
  while (b) {
    tie(a, b) = make_pair(b, a % b);
  }
  return a;
}
const long long N = 2e5 + 7;
long long n, q;
long long a[N], w[N], val[N];
vi ord;
long long pos[N];
struct ST {
  const long long INF = 1e9 + 7;
  long long n;
  vector<long long> mn, mx, prop, prop_val, sum;
  ST(long long n_) {
    n = n_;
    mn.assign(n << 2, 0);
    mx.assign(n << 2, 0);
    sum.assign(n << 2, 0);
    prop.assign(n << 2, 0);
    prop_val.assign(n << 2, INF);
  }
  void gap(long long v, long long l, long long r, long long first) {
    mn[v] += first;
    mx[v] += first;
    sum[v] += (r - l + 1) * first;
    if (prop_val[v] != INF)
      prop_val[v] += first;
    else
      prop[v] += first;
  }
  void gap_val(long long v, long long l, long long r, long long first) {
    mn[v] = mx[v] = first;
    sum[v] = (r - l + 1) * first;
    prop[v] = 0;
    prop_val[v] = first;
  }
  void push(long long v, long long l, long long r) {
    long long m = (l + r) >> 1;
    if (prop_val[v] != INF) {
      gap_val(v * 2 + 1, l, m, prop_val[v]);
      gap_val(v * 2 + 2, m + 1, r, prop_val[v]);
      prop_val[v] = INF;
    } else if (prop[v]) {
      gap(v * 2 + 1, l, m, prop[v]);
      gap(v * 2 + 2, m + 1, r, prop[v]);
      prop[v] = 0;
    }
  }
  void relax(long long v) {
    mn[v] = min(mn[v * 2 + 1], mn[v * 2 + 2]);
    mx[v] = max(mx[v * 2 + 1], mx[v * 2 + 2]);
    sum[v] = sum[v * 2 + 1] + sum[v * 2 + 2];
  }
  void add(long long v, long long tl, long long tr, long long l, long long r,
           long long first) {
    if (tr < l || r < tl) return;
    if (l <= tl && tr <= r) {
      gap(v, tl, tr, first);
      return;
    }
    long long tm = (tl + tr) >> 1;
    push(v, tl, tr);
    add(v * 2 + 1, tl, tm, l, r, first);
    add(v * 2 + 2, tm + 1, tr, l, r, first);
    relax(v);
  }
  void setval(long long v, long long tl, long long tr, long long l, long long r,
              long long first) {
    if (tr < l || r < tl) return;
    if (l <= tl && tr <= r) {
      gap_val(v, tl, tr, first);
      return;
    }
    long long tm = (tl + tr) >> 1;
    push(v, tl, tr);
    setval(v * 2 + 1, tl, tm, l, r, first);
    setval(v * 2 + 2, tm + 1, tr, l, r, first);
    relax(v);
  }
  long long getmin(long long v, long long tl, long long tr, long long l,
                   long long r) {
    if (tr < l || r < tl) return INF;
    if (l <= tl && tr <= r) return mn[v];
    long long tm = (tl + tr) >> 1;
    push(v, tl, tr);
    return min(getmin(v * 2 + 1, tl, tm, l, r),
               getmin(v * 2 + 2, tm + 1, tr, l, r));
  }
  long long getmax(long long v, long long tl, long long tr, long long l,
                   long long r) {
    if (tr < l || r < tl) return -INF;
    if (l <= tl && tr <= r) return mx[v];
    long long tm = (tl + tr) >> 1;
    push(v, tl, tr);
    return max(getmax(v * 2 + 1, tl, tm, l, r),
               getmax(v * 2 + 2, tm + 1, tr, l, r));
  }
  long long getsum(long long v, long long tl, long long tr, long long l,
                   long long r) {
    if (tr < l || r < tl) return 0;
    if (l <= tl && tr <= r) return sum[v];
    long long tm = (tl + tr) >> 1;
    push(v, tl, tr);
    return getsum(v * 2 + 1, tl, tm, l, r) +
           getsum(v * 2 + 2, tm + 1, tr, l, r);
  }
  void setpoint(long long v, long long tl, long long tr, long long i,
                long long first) {
    if (tl == tr) {
      mn[v] = mx[v] = sum[v] = first;
      return;
    }
    long long tm = (tl + tr) >> 1;
    push(v, tl, tr);
    if (i <= tm)
      setpoint(v * 2 + 1, tl, tm, i, first);
    else
      setpoint(v * 2 + 2, tm + 1, tr, i, first);
    relax(v);
  }
  void build(long long v, long long tl, long long tr, long long* a) {
    if (tl == tr) {
      mn[v] = mx[v] = sum[v] = a[tl];
      return;
    }
    long long tm = (tl + tr) >> 1;
    build(v * 2 + 1, tl, tm, a);
    build(v * 2 + 2, tm + 1, tr, a);
    relax(v);
  }
  void build(long long v, long long tl, long long tr, vi& a) {
    if (tl == tr) {
      mn[v] = mx[v] = sum[v] = a[tl];
      return;
    }
    long long tm = (tl + tr) >> 1;
    build(v * 2 + 1, tl, tm, a);
    build(v * 2 + 2, tm + 1, tr, a);
    relax(v);
  }
  void clear() {
    mn.assign(n << 2, 0);
    mx.assign(n << 2, 0);
    sum.assign(n << 2, 0);
    prop.assign(n << 2, 0);
    prop_val.assign(n << 2, INF);
  }
  void add(long long l, long long r, long long first) {
    add(0, 0, n - 1, l, r, first);
  }
  long long getmin(long long l, long long r) {
    return getmin(0, 0, n - 1, l, r);
  }
  long long getmax(long long l, long long r) {
    return getmax(0, 0, n - 1, l, r);
  }
  long long getsum(long long l, long long r) {
    return getsum(0, 0, n - 1, l, r);
  }
  void setpoint(long long i, long long first) {
    setpoint(0, 0, n - 1, i, first);
  }
  void setval(long long l, long long r, long long first) {
    setval(0, 0, n - 1, l, r, first);
  }
  void build(long long* a) { build(0, 0, n - 1, a); }
  void build(vi a) {
    assert(a.size() == n);
    build(0, 0, n - 1, a);
  }
  long long get_left_moq(long long v, long long tl, long long tr, long long l,
                         long long w) {
    if (tr < l || mx[v] < w) return -1;
    if (tl == tr) return tl;
    long long tm = (tl + tr) >> 1;
    push(v, tl, tr);
    long long t = get_left_moq(v * 2 + 1, tl, tm, l, w);
    if (t != -1)
      return t;
    else
      return get_left_moq(v * 2 + 2, tm + 1, tr, l, w);
  }
  long long get_left_moq(long long l, long long w) {
    return get_left_moq(0, 0, n - 1, l, w);
  }
  long long get_left_leq(long long v, long long tl, long long tr, long long l,
                         long long w) {
    if (tr < l || mn[v] > w) return -1;
    if (tl == tr) return tl;
    long long tm = (tl + tr) >> 1;
    push(v, tl, tr);
    long long t = get_left_leq(v * 2 + 1, tl, tm, l, w);
    if (t != -1)
      return t;
    else
      return get_left_leq(v * 2 + 2, tm + 1, tr, l, w);
  }
  long long get_left_leq(long long l, long long w) {
    return get_left_leq(0, 0, n - 1, l, w);
  }
};
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i] >> w[i] >> val[i];
    ord.push_back(i);
  }
  auto comp = [&](long long i, long long j) {
    return make_pair(-val[i], w[i]) < make_pair(-val[j], w[j]);
  };
  sort(ord.begin(), ord.end(), comp);
  for (long long i = 0; i < n; ++i) {
    pos[ord[i]] = i;
  }
  ST tree(n), mon(n);
  for (long long i = 0; i < n; ++i) {
    tree.add(pos[i], n - 1, a[i] * w[i]);
    mon.add(pos[i], pos[i], a[i] * val[i]);
  }
  while (q--) {
    long long t;
    cin >> t;
    if (t == 1) {
      long long k, d;
      cin >> k >> d;
      d--;
      tree.add(pos[d], n - 1, k * w[d]);
      mon.add(pos[d], pos[d], k * val[d]);
      a[d] += k;
    } else if (t == 2) {
      long long k, d;
      cin >> k >> d;
      d--;
      tree.add(pos[d], n - 1, -k * w[d]);
      mon.add(pos[d], pos[d], -k * val[d]);
      a[d] -= k;
    } else {
      long long have;
      cin >> have;
      long long l = 0, ans = 0;
      while (l < n) {
        long long left = 0;
        if (l) {
          left = tree.getsum(l - 1, l - 1);
        }
        long long p = tree.get_left_moq(l, have + left);
        if (p == -1) {
          ans += mon.getsum(l, n - 1);
          break;
        }
        long long skip = tree.getsum(l, p - 1);
        have -= skip;
        ans += mon.getsum(l, p - 1);
        long long who = ord[p];
        long long cnt = have / w[who];
        ans += cnt * val[who];
        have %= w[who];
        l = p + 1;
      }
      cout << ans << '\n';
    }
  }
}
