#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
struct point {
  __int128 x, y;
  point operator-(const point &b) const { return {x - b.x, y - b.y}; }
  __int128 operator*(const point &b) const { return x * b.y - b.x * y; }
};
__int128 K, b;
point st[N];
int top;
__int128 calc(point x) { return x.x * K + x.y + b; }
int rd() {
  int x = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x;
}
void print(__int128 x) {
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
signed main() {
  int n, m, opt, k;
  n = rd(), m = rd();
  st[top = 1] = {0, 0};
  while (m--) {
    opt = rd();
    if (opt == 1) {
      k = rd();
      n += k;
      K = b = 0;
      st[top = 1] = {0, 0};
    }
    if (opt == 2) {
      k = rd();
      point now = {n, -(n * K + b)};
      while (top > 1 && (now - st[top - 1]) * (st[top] - st[top - 1]) >= 0)
        --top;
      st[++top] = now;
      n += k;
    }
    if (opt == 3) b += rd(), K += rd();
    while (top > 1 && calc(st[top]) >= calc(st[top - 1])) --top;
    print(st[top].x + 1);
    putchar(' ');
    print(calc(st[top]));
    puts("");
  }
  return 0;
}
