#include <bits/stdc++.h>
using namespace std;
void read(long long &x) {
  x = 0;
  long long f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -f;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  x *= f;
}
void print(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (!x) return;
  print(x / 10), putchar(x % 10 + 48);
}
void write(long long x) {
  if (!x)
    putchar('0');
  else
    print(x);
  putchar('\n');
}
const long long maxn = 1e6 + 10;
const long long inf = 1e9;
const long double eps = 1e-8;
const long long mod = 1e9 + 7;
long long n, q, top, sum[maxn], suma, sumb;
struct P {
  long long x, y;
  P operator-(const P &a) const { return (P){x - a.x, y - a.y}; }
  long double operator*(const P &a) const {
    return (long double)x * a.y - (long double)y * a.x;
  }
} sta[maxn];
signed main() {
  read(n), read(q);
  n--;
  sta[++top] = (P){0, 0};
  for (long long i = 1; i <= q; i++) {
    long long op, a;
    read(op), read(a);
    if (op == 1) {
      suma = sumb = 0;
      top = 0;
      n += a;
      sta[++top] = (P){0, 0};
    } else if (op == 2) {
      long long x = n + 1, y = -suma * (n + 1) - sumb;
      n += a;
      while (top > 1 &&
             (sta[top - 1] - sta[top]) * ((P){x, y} - sta[top]) > 1.00)
        top--;
      sta[++top] = (P){x, y};
    } else {
      long long b;
      read(b);
      suma += b, sumb += a;
    }
    while (top > 1 && (long double)sta[top].x * suma + sta[top].y >=
                          (long double)sta[top - 1].x * suma + sta[top - 1].y)
      top--;
    printf("%lld %lld\n", sta[top].x + 1,
           sta[top].y + sta[top].x * suma + sumb);
  }
  return 0;
}
