#include <bits/stdc++.h>
const int N = 3e5 + 10;
inline int read() {
  int r = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') r = r * 10 + c - '0', c = getchar();
  return r;
}
long long st[N], top, K, B, sum, del[N];
const double eps = 1e-8;
int main() {
  int n = read(), m = read();
  st[++top] = 0;
  K = 1;
  B = 0;
  sum = n;
  for (int i = 1; i <= m; i++) {
    int opt = read();
    if (opt == 1) {
      int k = read();
      sum += k;
      st[top = 1] = 0;
      del[1] = 0;
      K = 1;
      B = 0;
    } else if (opt == 2) {
      int k = read();
      while (top > 1 &&
             (double)(-(K * st[top] + B - del[top])) / (sum - st[top]) <=
                 (double)(K * st[top] - del[top] - K * st[top - 1] +
                          del[top - 1]) /
                     (st[top] - st[top - 1]))
        --top;
      if (K * st[top] + B - del[top] > 0)
        st[++top] = sum, del[top] = K * sum + B;
      sum += k;
    } else {
      int b = read(), k = read();
      K += k;
      B += b;
      while (top > 1 &&
             K * st[top] - del[top] >= K * st[top - 1] - del[top - 1])
        --top;
    }
    printf("%lld %lld\n", st[top] + 1, K * st[top] + B - del[top]);
  }
  return 0;
}
