#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char now[1 << 16], *S, *T;
  if (T == S) {
    T = (S = now) + fread(now, 1, 1 << 16, stdin);
    if (T == S) return EOF;
  }
  return *S++;
}
inline long long read() {
  register long long x = 0, f = 1;
  char ch = gc();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = gc();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = gc();
  }
  return (f == 1) ? x : -x;
}
long long n, m, tot, x[1000001], K, B, sum, detk[1010101], detb[1010101];
inline long long get(long long id) {
  return (K + detk[id]) * x[id] + B + detb[id];
}
inline double slope(long long id1, long long id2) {
  return (double)(get(id2) - get(id1)) / (double)(x[id2] - x[id1]);
}
signed main() {
  sum = read(), m = read();
  x[tot = 1] = 0;
  for (int i = 1; i <= m; i++) {
    int opt = read();
    if (opt == 1) {
      sum += read();
      x[tot = 1] = 0;
      K = 0, B = 0;
      detk[tot] = 0, detb[tot] = 0;
    } else if (opt == 2) {
      x[++tot] = sum;
      detk[tot] = -K, detb[tot] = -B;
      sum += read();
      while (tot >= 3 && slope(tot - 2, tot - 1) >= slope(tot - 1, tot))
        tot--, x[tot] = x[tot + 1], detb[tot] = detb[tot + 1],
               detk[tot] = detk[tot + 1];
    } else {
      B += read(), K += read();
    }
    while (tot >= 2 && get(tot - 1) <= get(tot)) tot--;
    printf("%lld %lld\n", x[tot] + 1, get(tot));
  }
  return 0;
}
