#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, T b) {
  return b < a ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, T b) {
  return b > a ? a = b, 1 : 0;
}
inline int read() {
  int first(0), sgn(1);
  char ch(getchar());
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') sgn = -1;
  for (; isdigit(ch); ch = getchar()) first = (first * 10) + (ch ^ 48);
  return first * sgn;
}
void File() {}
const int N = 3e5 + 1e3;
pair<long long, long long> stk[N];
int top;
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);
}
int n, m;
long long k, b;
long long Calc(pair<long long, long long> p) {
  return k * p.first + p.second + b;
}
int main() {
  File();
  n = read();
  m = read();
  top = 1;
  while (m--) {
    int opt = read();
    if (opt == 1) top = 1, k = b = 0, n += read();
    if (opt == 2) {
      pair<long long, long long> cur = {n, -(n * k + b)};
      while (top > 1 && Slope(cur, stk[top]) <= Slope(stk[top - 1], stk[top]))
        --top;
      stk[++top] = cur;
      n += read();
    }
    if (opt == 3) b += read(), k += read();
    while (top > 1 && Calc(stk[top]) >= Calc(stk[top - 1])) --top;
    printf("%lld %lld\n", stk[top].first + 1, Calc(stk[top]));
  }
  return 0;
}
