#include <bits/stdc++.h>
using namespace std;
struct linearCHT {
  vector<long long> M;
  vector<long long> C;
  int pointer = 0;
  bool useless(int l1, int l2, int l3) {
    return 1.0 * (C[l3] - C[l1]) * (M[l1] - M[l2]) >
           1.0 * (C[l2] - C[l1]) * (M[l1] - M[l3]);
  }
  long long f(int id, long long x) { return M[id] * x + C[id]; }
  void add(long long m, long long c) {
    M.push_back(m);
    C.push_back(c);
    while (M.size() >= 3 && useless(M.size() - 3, M.size() - 2, M.size() - 1)) {
      M.erase(M.end() - 2);
      C.erase(C.end() - 2);
    }
  }
  pair<long long, long long> query(long long x) {
    pointer = M.size() - 1;
    while (pointer > 0 && f(pointer, x) >= f(pointer - 1, x)) {
      pointer--;
      M.pop_back();
      C.pop_back();
    }
    return pair<long long, long long>(M[pointer], f(pointer, x));
  }
  void clear() {
    M.clear();
    C.clear();
    pointer = 0;
  }
};
int main() {
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  long long bsum = 0;
  long long ssum = 0;
  linearCHT hull;
  hull.add(0, 0);
  while (m--) {
    long long op;
    cin >> op;
    if (op == 1) {
      long long k;
      cin >> k;
      hull.clear();
      hull.add(0, -bsum);
      n += k;
    } else if (op == 2) {
      long long k;
      cin >> k;
      hull.add(n, -bsum - ssum * n);
      n += k;
    } else {
      long long b, s;
      cin >> b >> s;
      bsum += b;
      ssum += s;
    }
    pair<long long, long long> qr = hull.query(ssum);
    cout << qr.first + 1 << " " << qr.second + bsum << "\n";
  }
  return 0;
}
