#include <bits/stdc++.h>
using namespace std;
inline void open(const char *s) {}
inline int rd() {
  static int x, f;
  x = 0;
  f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return f > 0 ? x : -x;
}
const int N = 300010;
int n, m;
pair<long long, long long> a[N];
int top = 0;
long long k = 0, b = 0;
inline long long f(pair<long long, long long> x) {
  return x.first * k + x.second + b;
}
inline long double slope(pair<long long, long long> a,
                         pair<long long, long long> b) {
  return 1. * (a.second - b.second) / (1. * (a.first - b.first));
}
int main() {
  open("hh");
  n = rd();
  m = rd();
  top = 1;
  while (m--) {
    int ty = rd();
    if (ty == 1) {
      int x = rd();
      n += x;
      a[top = 1] = pair<long long, long long>(0, 0);
      k = b = 0;
    } else if (ty == 2) {
      int x = rd();
      pair<long long, long long> hh =
          pair<long long, long long>(n, -(1ll * n * k + b));
      n += x;
      while (top > 1 && slope(hh, a[top - 1]) <= slope(a[top], a[top - 1]))
        --top;
      a[++top] = hh;
    } else
      b += rd(), k += rd();
    while (top > 1 && f(a[top]) >= f(a[top - 1])) --top;
    printf("%lld %lld\n", a[top].first + 1, f(a[top]));
  }
  return 0;
}
