#include <bits/stdc++.h>
using namespace std;
long long n, m;
const long long INF = 1e9 + 7;
long long B = 0, S = 0;
struct Line {
  long long a, b;
};
long long L, R;
vector<Line> a;
void init() {
  L = 0;
  R = n - 1;
  a.push_back({0, 0});
}
void addl(long long k) {
  a.clear();
  R += k;
  a.push_back({0, -B});
}
long long get(Line l) { return B + S * l.a + l.b; }
long long dup(long long a, long long b) { return (a + b - 1) / b; }
long long per(Line l, Line r) { return dup(l.b - r.b, r.a - l.a); }
void addr(long long k) {
  Line l = {R + 1, -B - S * (R + 1)};
  R += k;
  if (a.back().b <= l.b) return;
  while (2 <= a.size() &&
         per(a[a.size() - 2], a[a.size() - 1]) <= per(a[a.size() - 1], l))
    a.pop_back();
  a.push_back(l);
}
void upd(long long b, long long s) {
  B += b;
  S += s;
}
long long cnt = 0;
void print() {
  ++cnt;
  long long l = 0;
  long long r = (long long)a.size();
  while (l < r - 1) {
    long long m = (l + r) >> 1;
    if (get(a[m - 1]) <= get(a[m]))
      r = m;
    else
      l = m;
  }
  cout << a[l].a + 1 << ' ' << get(a[l]) << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  init();
  for (long long i = 0; i < m; ++i) {
    long long t;
    cin >> t;
    if (t == 1) {
      long long k;
      cin >> k;
      addl(k);
    } else if (t == 2) {
      long long k;
      cin >> k;
      addr(k);
    } else {
      long long b, s;
      cin >> b >> s;
      upd(b, s);
    }
    print();
  }
}
