#include <bits/stdc++.h>
const int N = 1050005;
const double eps = 1e-8;
struct ky {
  long long x, y;
  ky(const long long a = 0, const long long b = 0) { x = a, y = b; }
  ky operator-(const ky &p) const { return ky(x - p.x, y - p.y); }
  double operator*(const ky &p) const { return 1.0 * x * p.y - 1.0 * y * p.x; }
} s[N];
int top, Q;
long long n, k, b;
inline long long cal(const ky p) { return k * p.x + b + p.y; }
int main() {
  scanf("%lld%d", &n, &Q);
  register ky now;
  register int x, op;
  s[top = 1] = ky(0, 0);
  while (Q--) {
    scanf("%d", &op);
    if (op == 1) s[top = 1] = ky(0, 0), scanf("%d", &x), n += x, k = b = 0;
    if (op == 2) {
      now = ky(n, -(n * k + b)), scanf("%d", &x), n += x;
      while (top > 1 && (now - s[top - 1]) * (s[top] - s[top - 1]) > -eps)
        --top;
      s[++top] = now;
    }
    if (op == 3) scanf("%d", &x), b += x, scanf("%d", &x), k += x;
    while (top > 1 && cal(s[top]) >= cal(s[top - 1])) --top;
    printf("%lld %lld\n", s[top].x + 1, cal(s[top]));
  }
  return 0;
}
