#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long k = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    k = k * 10 + ch - '0';
    ch = getchar();
  }
  return k * f;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
const long long N = 3e5 + 10;
long long n, m, b, s, l, top;
struct ppap {
  long long x, y;
} st[N];
inline bool check(ppap x, ppap y, ppap z) {
  return (long double)(y.y - x.y) * (z.x - y.x) <
         (long double)(z.y - y.y) * (y.x - x.x);
}
signed main() {
  l = read();
  m = read();
  top = 1;
  st[top] = (ppap){0, 0};
  while (m--) {
    long long op = read();
    if (op == 1) {
      long long x = read();
      top = 1;
      b = s = 0;
      l += x;
      st[top] = (ppap){0, 0};
    }
    if (op == 2) {
      long long x = read();
      ppap now = (ppap){l, -s * l - b};
      l += x;
      while (top > 1 && !check(st[top - 1], st[top], now)) top--;
      st[++top] = now;
    }
    if (op == 3) {
      long long B = read(), S = read();
      b += B;
      s += S;
    }
    while (top > 1 &&
           st[top].y + st[top].x * s >= st[top - 1].y + st[top - 1].x * s)
      top--;
    write(st[top].x + 1);
    putchar(' ');
    writeln(st[top].y + st[top].x * s + b);
  }
  return 0;
}
