#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
struct fastio {
  char s[100000];
  int it, len;
  fastio() { it = len = 0; }
  inline char get() {
    if (it < len) return s[it++];
    it = 0;
    len = fread(s, 1, 100000, stdin);
    if (len == 0)
      return EOF;
    else
      return s[it++];
  }
  bool notend() {
    char c = get();
    while (c == ' ' || c == '\n') c = get();
    if (it > 0) it--;
    return c != EOF;
  }
} _buff;
inline long long getnum() {
  long long r = 0;
  bool ng = 0;
  char c;
  c = _buff.get();
  while (c != '-' && (c < '0' || c > '9')) c = _buff.get();
  if (c == '-') ng = 1, c = _buff.get();
  while (c >= '0' && c <= '9') r = r * 10 + c - '0', c = _buff.get();
  return ng ? -r : r;
}
template <class T>
inline void putnum(T x) {
  if (x < 0) putchar('-'), x = -x;
  register short a[20] = {}, sz = 0;
  while (x) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
inline char getreal() {
  char c = _buff.get();
  while (c <= 32) c = _buff.get();
  return c;
}
long long qpow(long long x, long long k) {
  return k == 0 ? 1
                : 1ll * qpow(1ll * x * x % mod, k >> 1) * (k & 1 ? x : 1) % mod;
}
struct line {
  long long k, b;
  line(long long K = 0, long long B = 0) : k(K), b(B) {}
  line operator+(const line &t) const { return line(k + t.k, b + t.b); }
  line operator-(const line &t) const { return line(k - t.k, b - t.b); }
  long long get(long long x) { return k * x + b; }
};
long long det(long long ax, long long ay, long long bx, long long by) {
  long double est = 1.0 * ax * by - 1.0 * ay * bx;
  if (est < -1e18) return -1e18;
  if (est > 1e18) return 1e18;
  return ax * by - ay * bx;
}
bool check(pair<long long, line> x, pair<long long, line> y,
           pair<long long, line> z, line lz) {
  x.second = x.second + lz;
  y.second = y.second + lz;
  z.second = z.second + lz;
  long long ax = z.first - x.first;
  long long ay = z.second.get(z.first) - x.second.get(x.first);
  long long bx = y.first - x.first;
  long long by = y.second.get(y.first) - x.second.get(x.first);
  if (det(ax, ay, bx, by) >= 0)
    return true;
  else
    return false;
}
struct Train {
  int n;
  line lz;
  vector<pair<long long, line> > v;
  void clear(int k) {
    v.clear();
    v.push_back(make_pair(0, line(0, 0)));
    n += k;
    lz = line(0, 0);
  }
  void add(int k) {
    v.push_back(make_pair(n, line(0, 0) - lz));
    while (v.size() >= 3) {
      if (check(v[v.size() - 3], v[v.size() - 2], v[v.size() - 1], lz)) {
        swap(v[v.size() - 2], v.back());
        v.pop_back();
      } else
        break;
    }
    n += k;
  }
  void add_line(line l) { lz = lz + l; }
  void query() {
    while (v.size() >= 2) {
      if ((lz + v.back().second).get(v.back().first) >=
          (lz + v[v.size() - 2].second).get(v[v.size() - 2].first))
        v.pop_back();
      else
        break;
    }
    putnum(v.back().first + 1), putchar(' '),
        putnum((v.back().second + lz).get(v.back().first)), putchar('\n');
  }
} T;
int main() {
  int n;
  n = getnum();
  T.clear(n);
  int m;
  m = getnum();
  for (int i = 0; i < m; i++) {
    int ti, k;
    ti = getnum(), k = getnum();
    if (ti == 1)
      T.clear(k);
    else if (ti == 2)
      T.add(k);
    else {
      int b;
      b = getnum();
      T.add_line(line(b, k));
    }
    T.query();
  }
  return 0;
}
