#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
long long k, b;
pair<long long, long long> p[maxn];
double Slope(pair<long long, long long> a, pair<long long, long long> b) {
  return 1.0 * (a.second - b.second) / (a.first - b.first);
}
long long cal(pair<long long, long long> x) {
  return k * x.first + x.second + b;
}
int main() {
  int n, m, r, op, x, y;
  scanf("%d%d", &n, &m);
  p[1] = make_pair(0, 0);
  r = 1;
  while (m--) {
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d", &x);
      r = 1, k = b = 0;
      n += x;
    } else if (op == 2) {
      pair<long long, long long> now = make_pair(n, -(n * k + b));
      while (r > 1 && Slope(now, p[r]) <= Slope(p[r], p[r - 1])) --r;
      p[++r] = now;
      scanf("%d", &x);
      n += x;
    } else {
      scanf("%d%d", &x, &y);
      b += x, k += y;
    }
    while (r > 1 && cal(p[r]) >= cal(p[r - 1])) r--;
    printf("%lld %lld\n", p[r].first + 1, cal(p[r]));
  }
}
