#include <bits/stdc++.h>
using namespace std;
template <typename tp>
inline void read(tp& x) {
  x = 0;
  char tmp;
  bool key = 0;
  for (tmp = getchar(); !isdigit(tmp); tmp = getchar()) key = (tmp == '-');
  for (; isdigit(tmp); tmp = getchar()) x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
struct point {
  long long x, y;
  point(long long x_ = 0, long long y_ = 0) : x(x_), y(y_) {}
  bool operator<(const point& a) const {
    if (x != a.x) return x < a.x;
    return y < a.y;
  }
  point operator+(const point& a) const { return point(x + a.x, y + a.y); }
  point operator-(const point& a) const { return point(x - a.x, y - a.y); }
};
long long cross(point a, point b) {
  if (b.y / b.x > a.y / a.x) return 1;
  if (b.y / b.x < a.y / a.x) return -1;
  long long k = b.y / b.x;
  b.y -= k * b.x;
  a.y -= k * a.x;
  b.y *= a.x;
  a.y *= b.x;
  if (b.y != a.y) return b.y < a.x ? -1 : 1;
  return 0;
}
const int N = 300010;
point que[N * 3], p;
int l, r, n, m;
long long cur, len, co;
long long calc(point a) { return a.x * cur + a.y + co; }
int main() {
  int tp, x, y;
  read(n), read(m);
  l = 1, r = 1;
  que[l] = point(0, 0);
  len = n;
  for (int _ = (1); _ <= (m); ++_) {
    read(tp);
    switch (tp) {
      case 1:
        read(x);
        len += x;
        cur = co = 0;
        p = point(0, 0);
        l = r = 1;
        que[l] = p;
        break;
      case 2:
        read(x);
        p = point(len, -cur * len - co);
        len += x;
        while (r - l >= 1 && cross(p - que[r], p - que[r - 1]) >= 0) --r;
        if (calc(p) < calc(que[r])) que[++r] = p;
        break;
      case 3:
        read(x), read(y);
        swap(x, y);
        cur += x;
        co += y;
        while (r - l >= 1 && calc(que[r]) >= calc(que[r - 1])) --r;
        break;
    }
    printf("%I64d %I64d\n", que[r].x + 1, calc(que[r]));
  }
  return 0;
}
