#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 3;
int n, m, l, r = 1, q[N], las;
long long det, len[N], sum[N], sb[N], ss[N], cha[N];
inline int in() {
  char c;
  int f = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') f = -1;
  int x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  return x * f;
}
inline long long calc(int t, int i) {
  return (sb[t] - sb[i]) + (ss[t] - ss[i]) * sum[i];
}
inline long long js(int i, int j) {
  if (calc(j, i) == 0) return cha[j];
  return (calc(j, i) - 1) / (sum[j] - sum[i]) + 1 + cha[j];
}
int main() {
  int op, x, y;
  n = in(), m = in(), len[0] = n, q[l = r = 1] = 0;
  for (int i = 1; i <= m; ++i) {
    op = in(), x = in(), sb[i] = sb[i - 1], ss[i] = ss[i - 1], cha[i] = det;
    if (op == 1) {
      len[i] = sum[las] + len[las] + x, sum[i] = 0, las = i;
      q[l = r = 1] = i, printf("%d %d\n", 1, 0);
    } else if (op == 2) {
      len[i] = x, sum[i] = sum[las] + len[las], las = i;
      while (l < r && js(q[r - 1], q[r]) <= js(q[r], i)) --r;
      q[++r] = i;
      while (l < r && det >= js(q[r - 1], q[r])) --r;
      printf("%lld %d\n", sum[q[r]] + 1, calc(i, q[r]));
    } else {
      y = in(), sb[i] += x, ss[i] += y, det += y, cha[i] = det;
      while (l < r && det >= js(q[r - 1], q[r])) --r;
      printf("%lld %lld\n", sum[q[r]] + 1, calc(i, q[r]));
    }
  }
  return 0;
}
