#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-6;
const int M = 3e5;
int Stop;
long long Ktot, Btot;
struct CPOINT {
  long long Vx, Vy;
  CPOINT(long long Ux = 0, long long Uy = 0) : Vx(Ux), Vy(Uy) {}
  long long Calc(long long Vk, long long Vb) { return Vy + Vb + Vx * Vk; }
} Sstk[M + 3];
double Tex(CPOINT Ca, CPOINT Cb) {
  return double(Cb.Vy - Ca.Vy) / (Cb.Vx - Ca.Vx);
}
int main() {
  long long n;
  int m;
  scanf("%lld%d", &n, &m);
  Sstk[Stop = 1] = CPOINT();
  while (m--) {
    int Itmp;
    scanf("%d", &Itmp);
    switch (Itmp) {
      case 1: {
        Sstk[Stop = 1] = CPOINT();
        int Ik;
        scanf("%d", &Ik);
        n += Ik;
        Ktot = Btot = 0;
        break;
      }
      case 2: {
        int Ik;
        scanf("%d", &Ik);
        CPOINT Cnew = CPOINT(n, -(n * Ktot + Btot));
        n += Ik;
        while (Stop > 1 &&
               Tex(Sstk[Stop - 1], Sstk[Stop]) >= Tex(Sstk[Stop], Cnew))
          Sstk[Stop--] = CPOINT();
        Sstk[++Stop] = Cnew;
        break;
      }
      case 3: {
        int Ib, Ik;
        scanf("%d%d", &Ib, &Ik);
        Btot += Ib;
        Ktot += Ik;
        break;
      }
    }
    while (Stop > 1 &&
           Sstk[Stop - 1].Calc(Ktot, Btot) <= Sstk[Stop].Calc(Ktot, Btot))
      Sstk[Stop--] = CPOINT();
    printf("%lld %lld\n", Sstk[Stop].Vx + 1, Sstk[Stop].Calc(Ktot, Btot));
  }
  return 0;
}
