#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long op[600010], QA[600010], QB[600010];
long long getans(pair<long long, long long> A, long long k, long long b) {
  return A.first * k + A.second + b;
}
long long calc(pair<long long, long long> A, pair<long long, long long> B) {
  long long dety = A.second - B.second;
  long long detx = B.first - A.first;
  if (dety % detx == 0) return dety / detx;
  return dety / detx + 1;
}
bool check(pair<long long, long long> A, pair<long long, long long> B,
           pair<long long, long long> C) {
  return calc(A, B) > calc(B, C);
}
void tryadd(vector<pair<long long, long long> > &V,
            pair<long long, long long> first) {
  if (first.second >= V.back().second) return;
  while (V.size() > 1 && !check(V[(long long)V.size() - 2], V.back(), first))
    V.pop_back();
  V.push_back(first);
}
void Solve(long long l, long long r, long long initot) {
  vector<pair<long long, long long> > V(0);
  V.push_back(pair<long long, long long>(0, 0));
  long long tot = initot;
  long long adds = 0, addb = 0;
  for (long long i = l; i <= r; i++) {
    if (op[i] == 2) {
      long long k = QA[i];
      tryadd(V, pair<long long, long long>(tot, -adds * tot - addb));
      tot += k;
    } else {
      adds += QB[i];
      addb += QA[i];
    }
    while (V.size() > 1 && getans(V[(long long)V.size() - 2], adds, addb) <=
                               getans(V.back(), adds, addb))
      V.pop_back();
    printf("%lld %lld\n", V.back().first + 1, getans(V.back(), adds, addb));
  }
}
signed main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= m; i++) {
    scanf("%lld%lld", &op[i], &QA[i]);
    if (op[i] == 3) scanf("%lld", &QB[i]);
  }
  op[++m] = 1;
  long long tot = n;
  for (long long i = 1, nxt; i <= m; i = nxt + 1) {
    long long tmptot = tot;
    for (nxt = i; op[nxt] != 1; nxt++) {
      if (op[nxt] == 2) tot += QA[nxt];
    }
    Solve(i, nxt - 1, tmptot);
    if (nxt < m) printf("1 0\n");
    tot += QA[nxt];
  }
  return 0;
}
