#include <bits/stdc++.h>
using namespace std;
using Int = long long;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <typename T, bool isMin>
struct ConvexHullTrick {
  struct P {
    T m, b;
    int idx;
    P(T m, T b, int idx) : m(m), b(b), idx(idx){};
    bool operator<(const P &a) { return m != a.m ? m < a.m : b < a.b; }
  };
  deque<P> L;
  inline pair<T, int> getY(const P &a, const T &x) {
    return make_pair(a.m * x + a.b, a.idx);
  }
  using D = long double;
  inline int sgn(T x) {
    if (x == 0) return x;
    return x < 0 ? -1 : 1;
  }
  inline bool check(const P &a, const P &b, const P &c) {
    if (b.b == a.b || c.b == b.b)
      return sgn(b.m - a.m) * sgn(c.b - b.b) >= sgn(c.m - b.m) * sgn(b.b - a.b);
    return D(b.m - a.m) / D(b.b - a.b) >= D(c.m - b.m) / D(c.b - b.b);
  }
  void addLine(T m, T b, int idx) {
    if (!isMin) m *= -1, b *= -1;
    P line(m, b, idx);
    if (empty() || L.front().m <= m) {
      while (L.size() >= 2 && check(line, L.front(), L[1])) L.pop_front();
      L.emplace_front(line);
    } else {
      assert(m <= L.back().m);
      while (L.size() >= 2 && check(L[L.size() - 2], L.back(), line))
        L.pop_back();
      L.emplace_back(line);
    }
  }
  bool empty() const { return L.empty(); }
  void clear() { L.clear(); }
  T query(T x) {
    assert(!empty());
    int low = -1, high = L.size() - 1;
    while (low + 1 < high) {
      int mid = (low + high) >> 1;
      if (getY(L[mid], x) >= getY(L[mid + 1], x))
        low = mid;
      else
        high = mid;
    }
    if (!isMin) return make_pair(-getY(L[high], x).first, L[high].idx);
    return getY(L[high], x);
  }
  pair<T, int> queryMonotoneInc(T x) {
    assert(!empty());
    while (L.size() >= 2 && getY(L.front(), x) >= getY(L[1], x)) L.pop_front();
    if (!isMin) return make_pair(-getY(L.front(), x).first, L.front().idx);
    return getY(L.front(), x);
  }
  pair<T, int> queryMonotoneDec(T x) {
    assert(!empty());
    while (L.size() >= 2 && getY(L.back(), x) >= getY(L[L.size() - 2], x))
      L.pop_back();
    if (!isMin) return make_pair(-getY(L.back(), x).first, L.back().idx);
    return getY(L.back(), x);
  }
};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  using ll = long long;
  ll n, m;
  cin >> n >> m;
  using CHT = ConvexHullTrick<ll, true>;
  CHT cht;
  ll bs = 0, ss = 0, len = n;
  cht.addLine(0, -bs, 0);
  for (int i = 0; i < m; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      ll k;
      cin >> k;
      cht.clear();
      cht.addLine(0, -bs, 0);
      len += k;
    }
    if (t == 2) {
      ll k;
      cin >> k;
      cht.addLine(len, -(bs + len * ss), len);
      len += k;
    }
    if (t == 3) {
      ll b, s;
      cin >> b >> s;
      bs += b;
      ss += s;
    }
    auto p = cht.queryMonotoneInc(ss);
    cout << p.second + 1 << " " << bs + p.first << "\n";
  }
  cout << flush;
  return 0;
}
