#include <bits/stdc++.h>
using namespace std;
const int Maxn = 300010;
const int inf = 2147483647;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return x * f;
}
long long n, sumk[Maxn], sumb[Maxn];
int m;
struct P {
  long long x;
  int t;
} p[Maxn];
int lp;
int q[Maxn], head = 1, tail = 1;
int T = 0;
long long calc(int i) {
  return p[i].x * (sumk[T] - sumk[p[i].t]) + sumb[T] - sumb[p[i].t];
}
double slope(int u, int v) {
  return ((double)calc(v) - calc(u)) / ((double)p[v].x - p[u].x);
}
int main() {
  n = read(), m = read();
  p[lp = 1].x = 1;
  p[1].t = 0;
  q[1] = 1;
  sumk[0] = sumb[0] = 0;
  while (m--) {
    int op = read();
    long long k, b, s;
    if (op == 1) {
      k = read();
      ++lp;
      p[lp].x = 1;
      p[lp].t = T;
      n += k;
      q[head = tail = 1] = lp;
    } else if (op == 2) {
      k = read();
      ++lp;
      p[lp].x = n + 1LL;
      p[lp].t = T;
      n += k;
      if (calc(q[tail]) != 0) {
        while (head < tail && slope(q[tail - 1], lp) >= slope(q[tail], lp))
          --tail;
        if (head == tail && calc(q[tail]) == calc(lp)) tail--;
        q[++tail] = lp;
      }
    } else {
      b = read(), s = read();
      b -= s;
      ++T;
      sumb[T] = sumb[T - 1] + b;
      sumk[T] = sumk[T - 1] + s;
      while (head < tail && calc(q[tail - 1]) <= calc(q[tail])) --tail;
    }
    printf("%lld %lld\n", p[q[tail]].x, calc(q[tail]));
  }
}
