#include <bits/stdc++.h>
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
using namespace std;
struct pnt {
  long long x, y;
  pnt(long long _x = 0, long long _y = 0) { x = _x, y = _y; }
  pnt operator+(const pnt &rhs) const { return pnt(x + rhs.x, y + rhs.y); }
};
int n, q;
long long sum_b = 0, sum_s = 0;
vector<pnt> ps;
template <class T>
void read(T &x) {
  char ch = x = 0;
  bool fl = false;
  while (!isdigit(ch)) fl |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  x = fl ? -x : x;
}
bool check_cross(pnt A, pnt B, pnt STD) {
  return (long double)(A.y - STD.y) / (A.x - STD.x) >=
         (long double)(B.y - STD.y) / (B.x - STD.x);
}
long long calc(pnt A) { return A.y + sum_b + sum_s * (A.x - 1); }
int main() {
  read(n), read(q);
  long long tot_sz = n;
  ps.push_back({1, 0});
  for (int i = 1, op, k, b, s; i <= q; i++) {
    read(op);
    if (op == 1) {
      read(k), tot_sz += k;
      ps.clear(), ps.push_back(pnt(1, 0));
      sum_b = sum_s = 0;
    }
    if (op == 2) {
      read(k);
      pnt tmp = pnt(tot_sz + 1, -calc(pnt(tot_sz + 1, 0)));
      while (ps.size() >= 2 &&
             check_cross(ps[ps.size() - 1], tmp, ps[ps.size() - 2]))
        ps.pop_back();
      if (calc(ps[ps.size() - 1]) > calc(tmp)) ps.push_back(tmp);
      tot_sz += k;
    }
    if (op == 3) {
      read(b), read(s);
      sum_b += b, sum_s += s;
      while (ps.size() >= 2 &&
             calc(ps[ps.size() - 1]) >= calc(ps[ps.size() - 2]))
        ps.pop_back();
    }
    printf("%lld %lld\n", ps.back().x, calc(ps.back()));
  }
  return 0;
}
