#include <bits/stdc++.h>
using namespace std;
namespace mine {
const int INF = 0x3f3f3f3f;
long long qread() {
  long long ans = 0;
  char c = getchar();
  int f = 1;
  while (c < '0' or c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ('0' <= c and c <= '9') ans = ans * 10 + c - '0', c = getchar();
  return ans * f;
}
void write(long long num) {
  if (num < 0) {
    num = -num;
    putchar('-');
  }
  if (num > 9) write(num / 10);
  putchar('0' + num % 10);
}
void writeln(int num) {
  write(num);
  puts("");
}
inline void chmax(int &x, int y) { x = x > y ? x : y; }
inline void chmin(int &x, int y) { x = x < y ? x : y; }
const int MAX_N = 310000;
pair<int, long long> q[MAX_N];
int top = 0;
void insert(pair<int, long long> now) {
  while (top > 1 and (long double)(q[top].second - q[top - 1].second) *
                             (now.first - q[top].first) >=
                         (long double)(now.second - q[top].second) *
                             (q[top].first - q[top - 1].first))
    top--;
  q[++top] = now;
}
pair<int, long long> ask(long long k) {
  while (top > 1 and (q[top].second - q[top - 1].second) >=
                         k * (q[top].first - q[top - 1].first))
    top--;
  return q[top];
}
void main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int cnt = n;
  long long kk = 0, bb = 0;
  top = 1;
  q[1] = make_pair(1, 0);
  while (m--) {
    int op = qread();
    if (op == 1)
      kk = bb = 0, top = 1, q[1] = make_pair(1, 0), cnt += qread();
    else if (op == 2)
      insert(make_pair(cnt + 1, -kk * (cnt + 1) - bb)), cnt += qread();
    else {
      long long b = qread(), k = qread();
      b -= k;
      kk += k;
      bb += b;
    }
    pair<int, long long> ans = ask(-kk);
    printf("%d %lld\n", ans.first, ans.second + kk * ans.first + bb);
  }
}
};  // namespace mine
int main() {
  srand(time(0));
  mine::main();
}
