#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
int m, i, j, k, cnt;
long long n, id[500005];
struct fun {
  bool sign, cat;
} F;
struct rec {
  long long x, y;
} a[500005];
int p = 0, q = 0, qu[500005];
void add(long long x, long long y, long long ID, const fun &F) {
  a[++cnt] = {x, y}, id[cnt] = ID;
  if (F.cat)
    while (q > p &&
           (long double)(a[qu[q]].x - a[qu[q - 1]].x) * (y - a[qu[q]].y) >=
               (long double)(a[qu[q]].y - a[qu[q - 1]].y) * (x - a[qu[q]].x))
      q--;
  else
    while (q > p &&
           (long double)(a[qu[q]].x - a[qu[q - 1]].x) * (y - a[qu[q]].y) <=
               (long double)(a[qu[q]].y - a[qu[q - 1]].y) * (x - a[qu[q]].x))
      q--;
  qu[++q] = cnt;
}
int opt(long long k, const fun &F) {
  if (F.cat)
    while (q > p &&
           a[qu[q - 1]].y + k * a[qu[q - 1]].x >= a[qu[q]].y + k * a[qu[q]].x)
      q--;
  else
    while (q > p &&
           a[qu[q - 1]].y + k * a[qu[q - 1]].x <= a[qu[q]].y + k * a[qu[q]].x)
      q--;
  return qu[q];
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m, F = {false, true};
  long long pre = 0, suf = n, head = 0, S = 0;
  a[0] = {0, 0};
  p = q = 0, qu[0] = 0;
  for (i = 1; i <= m; i++) {
    long long pat, x, y;
    cin >> pat;
    if (pat == 1) {
      cin >> x;
      pre += x, head = S = 0, q = p;
      cout << "1 0" << endl;
    } else if (pat == 2) {
      cin >> x;
      add(pre + suf, head + (pre + suf) * S, suf, F);
      j = opt(-S, F);
      cout << (j == 0 ? 1 : pre + id[j] + 1) << ' '
           << head - (a[j].y - S * a[j].x) << endl;
      suf += x;
    } else {
      cin >> x >> y;
      S += y, head += x;
      j = opt(-S, F);
      cout << (j == 0 ? 1 : pre + id[j] + 1) << ' '
           << head - (a[j].y - S * a[j].x) << endl;
    }
  }
  return 0;
}
