#include <bits/stdc++.h>
using namespace std;
const int MAXSIZE = 10000020;
int bufpos;
char buf[MAXSIZE];
void init() {
  buf[fread(buf, 1, MAXSIZE, stdin)] = '\0';
  bufpos = 0;
}
int readint() {
  int val = 0;
  for (; !isdigit(buf[bufpos]); bufpos++)
    ;
  for (; isdigit(buf[bufpos]); bufpos++) val = val * 10 + buf[bufpos] - '0';
  return val;
}
char readchar() {
  for (; isspace(buf[bufpos]); bufpos++)
    ;
  return buf[bufpos++];
}
int readstr(char* s) {
  int cur = 0;
  for (; isspace(buf[bufpos]); bufpos++)
    ;
  for (; !isspace(buf[bufpos]); bufpos++) s[cur++] = buf[bufpos];
  s[cur] = '\0';
  return cur;
}
const int maxn = 300002;
pair<long long, long long> stk[maxn];
long long a, b;
int tp;
int main() {
  init();
  long long n = readint();
  int m = readint();
  stk[++tp] = make_pair(0, 0);
  while (m--) {
    int op = readint();
    if (op == 1) {
      int k = readint();
      a = b = tp = 0;
      stk[++tp] = make_pair(0, 0);
      n += k;
      puts("1 0");
    } else if (op == 2) {
      int k = readint();
      if (stk[tp].second + a * stk[tp].first > -b) {
        pair<long long, long long> lol = make_pair(n, -a * n - b);
        while (tp > 1 &&
               (long double)(stk[tp].second - lol.second) /
                       (lol.first - stk[tp].first) >=
                   (long double)(stk[tp - 1].second - stk[tp].second) /
                       (stk[tp].first - stk[tp - 1].first))
          tp--;
        stk[++tp] = make_pair(n, -a * n - b);
      }
      printf("%lld 0\n", stk[tp].first + 1);
      n += k;
    } else {
      long long x = readint(), y = readint();
      a += y, b += x;
      while (tp > 1 && stk[tp].second + a * stk[tp].first >=
                           stk[tp - 1].second + a * stk[tp - 1].first)
        tp--;
      printf("%lld %lld\n", stk[tp].first + 1,
             stk[tp].second + stk[tp].first * a + b);
    }
  }
}
