#include <bits/stdc++.h>
using namespace std;
int n, m, top;
long long b, s;
struct node {
  long long x, y;
  node(long long x = 0, long long y = 0) : x(x), y(y) {}
} sta[300005];
int read() {
  char c = getchar();
  int x = 0;
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x;
}
double slope(node a, node b) {
  return (double)(a.y - b.y) / (double)(a.x - b.x);
}
long long calc(node a) { return a.x * s + a.y + b; }
int main() {
  n = read();
  m = read();
  sta[++top] = node(0, 0);
  while (m--) {
    int opt = read();
    if (opt == 1) {
      int k = read();
      b = s = 0;
      sta[top = 1] = node(0, 0);
      n += k;
    } else if (opt == 2) {
      int k = read();
      node cur(n, -b - s * n);
      n += k;
      while (top >= 2 && slope(sta[top - 1], sta[top]) > slope(sta[top], cur))
        --top;
      sta[++top] = cur;
    } else {
      int B = read(), S = read();
      b += B;
      s += S;
    }
    while (top >= 2 && calc(sta[top]) >= calc(sta[top - 1])) --top;
    printf("%I64d %I64d\n", sta[top].x + 1, calc(sta[top]));
  }
}
