#include <bits/stdc++.h>
using namespace std;
void solve(std::istream &in, std::ostream &out);
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  solve(std::cin, std::cout);
  return 0;
}
struct point {
  int64_t x, y;
  point() = default;
  point(int64_t x, int64_t y) : x(x), y(y) {}
  point operator-(const point &b) const { return point(x - b.x, y - b.y); }
};
bool check(point p, point q, point r) {
  point pp = p - q, rr = r - q;
  return (long double)pp.x * rr.y >= (long double)pp.y * rr.x;
}
void solve(std::istream &in, std::ostream &out) {
  int64_t n;
  int m;
  cin >> n >> m;
  int64_t add = 0, slope = 0;
  vector<point> hull(1, point(0, 0));
  while (m--) {
    int type;
    cin >> type;
    if (type == 1) {
      int cnt;
      cin >> cnt;
      hull.clear();
      hull.emplace_back(0, 0);
      n += cnt;
      add = slope = 0;
    } else if (type == 2) {
      int cnt;
      cin >> cnt;
      while (hull.size() > 1 &&
             check(point(n, -(n * slope + add)), hull[hull.size() - 2],
                   hull[hull.size() - 1])) {
        hull.pop_back();
      }
      hull.emplace_back(n, -(n * slope + add));
      n += cnt;
    } else {
      int b, s;
      cin >> b >> s;
      add += b;
      slope += s;
    }
    while (hull.size() > 1 &&
           slope * hull.back().x + hull.back().y >=
               slope * hull[hull.size() - 2].x + hull[hull.size() - 2].y) {
      hull.pop_back();
    }
    cout << hull.back().x + 1 << " "
         << slope * hull.back().x + hull.back().y + add << "\n";
  }
}
