#include <bits/stdc++.h>
using namespace std;
struct line {
  long long m, y;
  long long eval(long long x) { return m * x + y; }
};
int q, op, sz;
long long s, b, k, l, n;
line st[300005];
bool f(long long m3, long long y3) {
  long long m1 = st[sz - 2].m, y1 = st[sz - 2].y;
  long long m2 = st[sz - 1].m, y2 = st[sz - 1].y;
  return (y2 - y1) / (m1 - m2) < (y3 - y2) / (m2 - m3);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  st[sz++] = {0, 0};
  while (q--) {
    cin >> op >> k;
    if (op == 1) {
      s = b = 0;
      sz = 1;
      n += k;
    } else if (op == 2) {
      while (sz > 1 && f(n, -b - n * s)) sz--;
      st[sz++] = {n, -b - n * s};
      n += k;
    } else {
      cin >> l;
      b += k, s += l;
    }
    while (sz > 1 && st[sz - 1].eval(s) >= st[sz - 2].eval(s)) sz--;
    cout << st[sz - 1].m + 1 << " " << st[sz - 1].eval(s) + b << endl;
  }
  return 0;
}
