#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
long long k, b;
struct dt {
  int x;
  long long v;
  dt(int X = 0, long long V = 0) : x(X), v(V) {}
  long long val() const { return k * x + b + v; }
};
bool rep(const dt &a, const dt &b, const dt &c) {
  return double(b.val() - a.val()) / (b.x - a.x) >
         double(c.val() - b.val()) / (c.x - b.x);
}
template <class T>
struct myque {
  static const size_t qs = N;
  size_t head, tail;
  T q[qs + 5];
  static size_t loopinc(size_t x) { return x == qs ? 0 : x + 1; }
  static size_t loopdec(size_t x) { return x == 0 ? qs : x - 1; }
  myque() : head(0), tail(0) {}
  void pushback(T x) { q[tail] = x, tail = loopinc(tail); }
  size_t size() const { return (tail + qs - head) % qs; }
  bool empty() const { return head == tail; }
  void popback() { tail = loopdec(tail); }
  void clear() { head = tail = 0; }
  T back() const { return q[loopdec(tail)]; }
  T back2() const { return q[loopdec(loopdec(tail))]; }
};
myque<dt> q;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  --n;
  q.pushback(dt(0, 0));
  while (m--) {
    int op, x, y;
    dt tmp;
    scanf("%d%d", &op, &x);
    if (op == 1) {
      tmp = dt(0, 0), tmp.v = -tmp.val();
      n += x;
      q.clear(), q.pushback(tmp);
    } else if (op == 2) {
      tmp = dt(n + 1, 0), tmp.v = -tmp.val();
      n += x;
      while (q.size() >= 2 && rep(q.back2(), q.back(), tmp)) q.popback();
      q.pushback(tmp);
    } else {
      scanf("%d", &y);
      k += y, b += x;
    }
    while (q.size() >= 2 && q.back2().val() <= q.back().val()) q.popback();
    printf("%d %lld\n", q.back().x + 1, q.back().val());
  }
  return 0;
}
