#include <bits/stdc++.h>
using namespace std;
int n, m, tp;
long long k, b;
int read() {
  int x = 0, F = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') F = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * F;
}
struct point {
  long long x, y;
  point operator-(const point &B) const { return (point){x - B.x, y - B.y}; }
  long double operator*(const point &B) const {
    return (long double)x * B.y - (long double)y * B.x;
  }
} stk[300000 + 5];
long long cal(point A) { return A.y + k * A.x + b; }
int main() {
  n = read(), m = read();
  stk[++tp] = (point){0, 0};
  while (m--) {
    int opt = read();
    if (opt == 1) {
      stk[tp = 1] = (point){0, 0};
      n += read();
      k = 0, b = 0;
    } else if (opt == 2) {
      point np = (point){n, -(n * k + b)};
      n += read();
      while (tp > 1 && (np - stk[tp - 1]) * (stk[tp] - stk[tp - 1]) > -10e-6)
        tp--;
      stk[++tp] = np;
    } else {
      b += read(), k += read();
    }
    while (tp > 1 && cal(stk[tp]) >= cal(stk[tp - 1])) tp--;
    printf("%lld %lld\n", stk[tp].x + 1, cal(stk[tp]));
  }
}
