#include <bits/stdc++.h>
const long double eps = 1e-6;
struct Point {
  long long x, y;
  Point(long long _x = 0, long long _y = 0) : x(_x), y(_y) {}
  Point operator-(const Point &B) const { return Point(x - B.x, y - B.y); }
  long double operator*(const Point &B) const {
    return (long double)x * B.y - (long double)y * B.x;
  }
} stk[1023000];
int top;
long long k, b;
long long calc(Point A) { return A.y + k * A.x + b; }
int read() {
  int n = 0;
  char a;
  bool z = false;
  while (a = getchar()) {
    if (a > '9' || a < '0')
      if (z)
        break;
      else
        continue;
    if (!z) z = true;
    n = (n << 3) + (n << 1) + (a ^ 48);
  }
  return n;
}
int main() {
  long long n = read();
  int Q = read(), opt;
  Point now;
  stk[top = 1] = Point();
  while (Q--) {
    opt = read();
    switch (opt) {
      case 1:
        stk[top = 1] = Point();
        n += read();
        k = b = 0;
        break;
      case 2:
        now = Point(n, -(n * k + b));
        n += read();
        while (top > 1 &&
               (now - stk[top - 1]) * (stk[top] - stk[top - 1]) > -eps)
          --top;
        stk[++top] = now;
        break;
      case 3:
        b += read();
        k += read();
        break;
    }
    while (top > 1 && calc(stk[top]) >= calc(stk[top - 1])) --top;
    printf("%lld %lld\n", stk[top].x + 1, calc(stk[top]));
  }
  return 0;
}
