#include <bits/stdc++.h>
using namespace std;
struct car {
  int pos;
  long long val;
  car(){};
  car(int _pos, long long _val) : pos(_pos), val(_val){};
  bool operator<(const car &a) const { return pos < a.pos; }
};
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  long long gpos = 0, gval = 0;
  int len = n;
  set<car> cur;
  cur.insert(car(0, 0));
  priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                 greater<pair<long long, int>>>
      to;
  auto eval = [&](car a) { return a.val + gval + gpos * a.pos; };
  while (m--) {
    int id;
    scanf("%d", &id);
    if (id == 2) {
      int k;
      scanf("%d", &k);
      car foo(len, -gpos * len - gval);
      len += k;
      if (cur.size()) {
        auto it = prev(cur.end());
        if (eval(*it)) {
          long long dis = foo.pos - it->pos;
          to.push(make_pair(gpos + (eval(*it) - eval(foo) + dis - 1) / dis,
                            foo.pos));
          cur.insert(foo);
        }
      } else
        cur.insert(foo);
    }
    if (id == 3) {
      int b, s;
      scanf("%d%d", &b, &s);
      gval += b;
      gpos += s;
      while (to.size()) {
        auto baz = to.top();
        if (baz.first > gpos) break;
        to.pop();
        int v = baz.second;
        auto it = cur.find(car(v, 0));
        if (it == cur.end() || it == cur.begin()) continue;
        auto l = prev(it);
        if (eval(*it) < eval(*l)) continue;
        if (it != prev(cur.end())) {
          auto r = next(it);
          long long dis = r->pos - l->pos;
          to.push(
              make_pair(gpos + (eval(*l) - eval(*r) + dis - 1) / dis, r->pos));
        }
        cur.erase(it);
      }
    }
    if (id == 1) {
      int k;
      scanf("%d", &k);
      gpos = gval = 0;
      len += k;
      cur.clear();
      priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                     greater<pair<long long, int>>>
          _to;
      swap(to, _to);
      cur.insert(car(0, 0));
    }
    printf("%d %lld\n", prev(cur.end())->pos + 1, eval(*prev(cur.end())));
  }
  return 0;
}
