#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
using ll = signed long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAXN = 5e3 + 10;
int n, m, d;
struct point {
  ll x, y;
  point(ll x = 0, ll y = 0) : x(x), y(y) {}
  point operator-(const point &b) const { return point(x - b.x, y - b.y); }
};
ll add = 0, slope = 0;
point get(point a) { return point(a.x, a.y + a.x * slope + add); }
bool check(point a, point b, point c) {
  a = get(a), b = get(b), c = get(c);
  b = b - a;
  c = c - a;
  return (long double)b.y * c.x <= (long double)c.y * b.x;
}
void MAIN() {
  ll n;
  int m;
  cin >> n >> m;
  vector<point> hull(1, point(0, 0));
  while (m--) {
    int type;
    cin >> type;
    if (type == 1) {
      int cnt;
      cin >> cnt;
      hull.clear();
      hull.push_back(point(0, 0));
      n += cnt;
      add = slope = 0;
    } else if (type == 2) {
      int cnt;
      cin >> cnt;
      point cur(n, -(n * slope + add));
      while (hull.size() > 1 && check(cur, hull.back(), hull[hull.size() - 2]))
        hull.pop_back();
      hull.push_back(cur);
      n += cnt;
    } else {
      int b, s;
      cin >> b >> s;
      add += b;
      slope += s;
    }
    while (hull.size() > 1 &&
           hull.back().x * slope + hull.back().y >=
               hull[hull.size() - 2].x * slope + hull[hull.size() - 2].y)
      hull.pop_back();
    cout << hull.back().x + 1 << " "
         << hull.back().x * slope + hull.back().y + add << endl;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int TC = 1;
  for (int tc = (0); tc < (TC); tc++) {
    MAIN();
  }
  return 0;
}
