#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 5e5 + 50;
const int inf = 1e8;
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, op, x, y, tail;
  cin >> n >> m;
  p[tail = 1] = make_pair(0, 0);
  while (m--) {
    cin >> op;
    if (op == 1) {
      cin >> x;
      tail = 1, k = b = 0;
      n += x;
    } else if (op == 2) {
      pair<long long, long long> now = make_pair(n, -(n * k + b));
      while (tail > 1 && -slope(now, p[tail]) >= -slope(p[tail], p[tail - 1]))
        tail--;
      p[++tail] = now;
      cin >> x;
      n += x;
    } else
      cin >> x >> y, b += x, k += y;
    while (tail > 1 && cal(p[tail]) >= cal(p[tail - 1])) tail--;
    cout << p[tail].first + 1 << " " << cal(p[tail]) << endl;
  }
  return 0;
}
