#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long a = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    a = a * 10 + c - 48;
    c = getchar();
  }
  return a;
}
const long long MAXN = 3e5 + 7;
pair<long long, long long> first[MAXN];
long long K, B, top, all;
long double getK(pair<long long, long long> a, pair<long long, long long> b) {
  return (b.second - a.second) * 1.0 / (a.first - b.first);
}
long long calc(pair<long long, long long> second) {
  return (second.first - 1) * K + second.second + B;
}
signed main() {
  all = read();
  first[top = 1] = pair<long long, long long>(1, 0);
  for (long long M = read(); M; --M) {
    long long tp = read();
    if (tp == 1) {
      first[top = 1] = pair<long long, long long>(1, 0);
      B = K = 0;
      all += read();
    } else if (tp == 2) {
      pair<long long, long long> now = pair<long long, long long>(
          all + 1, -calc(pair<long long, long long>(all + 1, 0)));
      while (top > 1 &&
             getK(now, first[top]) >= getK(first[top], first[top - 1]))
        --top;
      first[++top] = now;
      all += read();
    } else {
      B += read();
      K += read();
    }
    while (top > 1 && calc(first[top]) >= calc(first[top - 1])) --top;
    cout << first[top].first << ' ' << calc(first[top]) << endl;
  }
  return 0;
}
