#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
auto& errStream = cerr;
class CerrDummy {
} cerrDummy;
template <class T>
CerrDummy& operator<<(CerrDummy& cd, const T&) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy& cd,
                      basic_ostream<charTDummy, traitsDummy>&(
                          basic_ostream<charTDummy, traitsDummy>&)) {
  return cd;
}
using pi = pair<ll, ll>;
using vi = vector<ll>;
using ld = long double;
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (ll i = ll(0); i < ll((ll)v.size()); i++) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}
template <ll i, class T>
void print_tuple(ostream&, const T&) {}
template <ll i, class T, class H, class... Args>
void print_tuple(ostream& os, const T& t) {
  if (i) os << ",";
  os << get<i>(t);
  print_tuple<i + 1, T, Args...>(os, t);
}
template <class... Args>
ostream& operator<<(ostream& os, const tuple<Args...>& t) {
  os << "(";
  print_tuple<0, tuple<Args...>, Args...>(os, t);
  return os << ")";
}
ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}
void printSpace() { printf(" "); }
void printEoln() { printf("\n"); }
void print(ll x, ll suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}
template <class T>
void print(const vector<T>& v) {
  for (ll i = ll(0); i < ll(v.size()); i++)
    print(v[i], i == ll(v.size()) - 1 ? 1 : 2);
}
string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}
char* readCharArray() {
  static char buf[3341000];
  static ll bufUsed = 0;
  char* ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}
template <class T, class U>
void chmax(T& a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
void chmin(T& a, U b) {
  if (b < a) a = b;
}
template <class T>
T Sq(const T& t) {
  return t * t;
}
void Yes(bool ex = true) {
  cout << "YES" << endl;
  if (ex) exit(0);
}
void No(bool ex = true) {
  cout << "NO" << endl;
  if (ex) exit(0);
}
const ll infLL = LLONG_MAX / 3;
const ll inf = infLL;
constexpr ll Ten(ll n) { return n == 0 ? 1 : Ten(n - 1) * 10; }
template <class T>
vector<T> Uniqued(const vector<T>& vv) {
  auto v(vv);
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}
template <class T>
void MakeUniqued(vector<T>& v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
bool cmpfrac(ll ax, ll ay, ll bx, ll by) {
  ll p = ay / ax, q = by / bx;
  ll r = ay % ax, s = by % bx;
  if (r < 0) {
    p--;
    r += ax;
  }
  if (s < 0) {
    q--;
    s += bx;
  }
  if (p != q) return p < q;
  return r * bx < s * ax;
}
bool cmp(pi a, pi b, pi c) {
  ll ax = b.first - a.first, ay = b.second - a.second;
  ll bx = c.first - b.first, by = c.second - b.second;
  return cmpfrac(ax, ay, bx, by);
}
signed main() {
  ll n = read(), m = read();
  deque<pi> cur;
  cur.push_back(pi(0, 0));
  ll head = 0, tail = n, a = 0, b = 0;
  auto eval = [&](pi x) { return a * x.first + x.second + b; };
  auto cmp2 = [&](pi x, pi y, pi z) {
    return cmp(pi(x.first, eval(x)), pi(y.first, eval(y)),
               pi(z.first, eval(z)));
  };
  for (ll _ = ll(0); _ < ll(m); _++) {
    ll t = read();
    if (t == 1) {
      ll k = read();
      ll x = head - k;
      ll y = -a * x - b;
      while (cur.size() >= 2) {
        if (cmp2(pi(x, y), cur[0], cur[1])) break;
        cur.pop_front();
      }
      cur.push_front(pi(x, y));
      head -= k;
    } else if (t == 2) {
      ll k = read();
      ll x = tail;
      ll y = -a * x - b;
      while (cur.size() >= 2) {
        ll s = cur.size();
        if (cmp2(cur[s - 2], cur[s - 1], pi(x, y))) break;
        cur.pop_back();
      }
      cur.push_back(pi(x, y));
      tail += k;
    } else {
      ll p = read(), q = read();
      a += q;
      b += p - head * q;
    }
    ll s = cur.size();
    ll lw = 0, up = s - 1;
    while (1) {
      const ll m1 = (lw * 2 + up) / 3;
      const ll m2 = (lw + up * 2) / 3;
      if (m1 == m2) break;
      if (eval(cur[m1]) <= eval(cur[m2])) {
        if (up == m2) break;
        up = m2;
      } else {
        if (lw == m1) break;
        lw = m1;
      }
    }
    pi ans(inf, inf);
    for (ll i = ll(lw); i < ll(up + 1); i++) {
      chmin(ans, pi(eval(cur[i]), cur[i].first));
    }
    print(ans.second - head + 1, 2);
    print(ans.first);
  }
}
