#include <bits/stdc++.h>
using std::cerr;
using std::endl;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int MAXM = 300005;
const double eps = 1e-8;
int m, cnt, top, sta[MAXM];
long long n, nowk, nowb;
inline long double lfabs(long double x) { return x >= 0 ? x : -x; }
inline long double dcmp(long double x, long double y) {
  if (lfabs(x - y) < eps) return 0;
  if (x < y)
    return -1;
  else
    return 1;
}
struct point {
  long long x, y;
  inline friend point operator+(point a, point b) {
    return (point){a.x + b.x, a.y + b.y};
  }
  inline friend point operator-(point a, point b) {
    return (point){a.x - b.x, a.y - b.y};
  }
} a[MAXM];
inline long double cross(point a, point b) {
  return (long double)a.x * b.y - (long double)a.y * b.x;
}
inline bool toleft(point a, point b, point c) {
  return dcmp(cross(b - a, c - b), 0) > 0;
}
int main() {
  n = read(), m = read();
  a[++cnt] = (point){1, 0};
  sta[++top] = 1;
  for (int i = (1); i <= (m); ++i) {
    int opt = read();
    if (opt == 1) {
      int k = read();
      n += k;
      cnt = top = nowk = nowb = 0;
      a[++cnt] = (point){1, 0};
      sta[++top] = 1;
    } else if (opt == 2) {
      int k = read();
      ++n;
      a[++cnt] = (point){n, -nowk * (n - 1) - nowb};
      while (top >= 2 && !toleft(a[sta[top - 1]], a[sta[top]], a[cnt])) --top;
      sta[++top] = cnt;
      n += k - 1;
    } else
      nowb += read(), nowk += read();
    while (top >= 2 && a[sta[top]].y - a[sta[top - 1]].y +
                               nowk * (a[sta[top]].x - a[sta[top - 1]].x) >=
                           0)
      --top;
    printf("%I64d %I64d\n", a[sta[top]].x,
           a[sta[top]].y + nowk * (a[sta[top]].x - 1) + nowb);
  }
  return 0;
}
