#include <bits/stdc++.h>
using namespace std;
int n, m, top;
long long h, t, B, S;
pair<long long, int> sta[300005];
inline long long get(pair<long long, int> x) {
  return x.first + B + (x.second - 1) * S;
}
inline bool cross(pair<long long, int> a, pair<long long, int> b,
                  pair<long long, int> c) {
  a.first -= c.first, a.second -= c.second;
  b.first -= c.first, b.second -= c.second;
  return 1. * a.first / b.first >= 1. * a.second / b.second;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  h = 0, t = n;
  sta[top = 1] = make_pair(0, 1);
  while (m--) {
    int op;
    cin >> op;
    if (op == 1) {
      int k;
      cin >> k;
      top = 1;
      B = S = 0;
      h += k;
      sta[1] = make_pair(0, 1);
    } else if (op == 2) {
      int k;
      cin >> k;
      if (get(sta[top]) > 0) {
        pair<long long, int> p = make_pair(-B - S * (h + t), h + t + 1);
        while (top && cross(p, sta[top], sta[top - 1])) --top;
        sta[++top] = p;
      }
      t += k;
    } else {
      int b, s;
      cin >> b >> s;
      B += b, S += s;
      while (top > 1 && get(sta[top]) >= get(sta[top - 1])) --top;
    }
    cout << sta[top].second << ' ' << get(sta[top]) << '\n';
  }
  return 0;
}
