#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7;
struct line {
  long long k, b, i;
};
double getx(line l1, line l2) { return 1.0 * (l1.b - l2.b) / (l2.k - l1.k); }
long long gety(line l, long long x) { return l.k * x + l.b; }
struct Queue {
  line q[N];
  int t;
  void clear() { q[t = 1] = {0, 0, 1}; }
  void ins(line x) {
    while (t > 1 && getx(x, q[t]) > getx(q[t], q[t - 1])) t--;
    q[++t] = x;
  }
  long long query(long long x) {
    while (t > 1 && getx(q[t], q[t - 1]) <= x) t--;
    return gety(q[t], x);
  }
  long long get() { return q[t].i; }
} Q;
int main() {
  long long n;
  int m;
  scanf("%lld%d", &n, &m);
  long long b = 0, s = 0;
  Q.clear();
  for (int i = 1; i <= m; i++) {
    int op, x, y;
    scanf("%d%d", &op, &x);
    if (op == 1) {
      Q.clear();
      b = 0, s = 0;
      n += x;
    } else if (op == 2) {
      Q.ins({n, -b - s * n, n + 1});
      n += x;
    } else {
      scanf("%d", &y);
      b += x, s += y;
    }
    long long ans = Q.query(s) + b;
    printf("%lld %lld\n", Q.get(), ans);
  }
  return 0;
}
