#include <bits/stdc++.h>
using namespace std;
const int N = 300003;
int n, m;
long long b[N], s[N];
struct data {
  int num, x;
} st[N];
int L;
inline int sign(long long &x) {
  if (x > 0) return 1;
  if (x < 0) return -1;
  return 0;
}
inline int mul(long long _x1, long long _y1, long long _x2, long long _y2) {
  int w1 = sign(_x1) * sign(_y2), w2 = sign(_y1) * sign(_x2);
  if (w1 != w2) return w1 > w2;
  if (w1 == 0) return 0;
  return (long double)_x1 * _y2 > (long double)_y1 * _x2;
}
void read(int &x) { scanf("%d", &x); }
void read(long long &x) { scanf("%lld", &x); }
void chkmin(long long &x, long long y) {
  if (y < x) x = y;
}
inline long long cal(data q, int w) {
  return b[w] - b[q.num] + 1ll * (q.x - 1) * (s[w] - s[q.num]);
}
void AddPoint(int w, int x) {
  if (cal(st[L], w) == 0) return;
  long long y = cal((data){w, x}, w);
  while (L >= 2) {
    if (mul(st[L].x - st[L - 1].x, cal(st[L], w) - cal(st[L - 1], w),
            x - st[L].x, y - cal(st[L], w)))
      break;
    L--;
  }
  st[++L] = (data){w, x};
}
void PopBack(int w) {
  while (L >= 2 && cal(st[L], w) >= cal(st[L - 1], w)) L--;
}
int main() {
  read(n);
  read(m);
  int tp;
  long long x, y;
  st[L = 1] = (data){0, 1};
  for (int i = (1); i <= (m); i++) {
    b[i] = b[i - 1];
    s[i] = s[i - 1];
    read(tp);
    read(x);
    if (tp == 1) {
      b[i] = s[i] = 0;
      st[L = 1] = (data){i, 1};
      n += x;
    } else if (tp == 2) {
      AddPoint(i, n + 1);
      n += x;
    } else {
      read(y);
      b[i] += x;
      s[i] += y;
      PopBack(i);
    }
    printf("%d %lld\n", st[L].x, cal(st[L], i));
  }
  return 0;
}
