#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 2;
long long st[N], zb[N], k, b, cd, y;
int tp, m, c, x;
inline void read(int &x) {
  c = getchar();
  while ((c < 48) || (c > 57)) c = getchar();
  x = c ^ 48;
  c = getchar();
  while ((c >= 48) && (c <= 57)) {
    x = x * 10 + (c ^ 48);
    c = getchar();
  }
}
int main() {
  read(x);
  cd = x;
  tp = 1;
  read(m);
  zb[1] = 1;
  for (; m--; printf("%lld %lld\n", zb[tp], st[tp] + zb[tp] * k + b)) {
    read(x);
    if (x == 1) {
      read(x);
      cd += x;
      tp = 1;
      k = b = 0;
      continue;
    }
    if (x == 2) {
      read(x);
      y = -k * (cd + 1) - b;
      if (st[tp] == -k * zb[tp] - b) {
        cd += x;
        continue;
      }
      while ((tp > 1) &&
             ((long double)(st[tp] - y) * (zb[tp] - zb[tp - 1]) >=
              (long double)(st[tp - 1] - st[tp]) * (cd + 1 - zb[tp])))
        --tp;
      zb[++tp] = cd + 1;
      st[tp] = y;
      cd += x;
      continue;
    }
    read(x);
    b += x;
    read(x);
    k += x;
    b -= x;
    while ((tp > 1) &&
           ((st[tp - 1] - st[tp]) <= (long double)(zb[tp] - zb[tp - 1]) * k))
      --tp;
  }
}
