#include <bits/stdc++.h>
int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  int start_ncar, nquery;
  std::cin >> start_ncar >> nquery;
  int offset = 0;
  int64_t sumb = 0, sums = 0;
  struct car {
    int pos;
    int64_t val;
  };
  auto const realval = [&](car c) { return c.val + sumb + sums * c.pos; };
  std::vector<car> train{{0, 0}};
  int endpos = start_ncar;
  auto const add_back = [&](int index, int64_t realval_) {
    int pos = index - offset;
    car c{pos, realval_ - sumb - sums * pos};
    assert(realval(c) == realval_);
    if (train.empty()) {
      train.push_back(c);
      return;
    }
    if (realval_ >= realval(train.back())) return;
    for (unsigned i = 1; i < train.size(); ++i)
      assert(realval(train[i - 1]) > realval(train[i]));
    while (train.size() >= 2) {
      std::pair<int, int64_t> x{train.end()[-2].pos, realval(train.end()[-2])},
          y{train.back().pos, realval(train.back())}, z{c.pos, realval_},
          v1{y.first - x.first, y.second - x.second},
          v2{z.first - y.first, z.second - y.second};
      double v1_cross_v2 =
          (double)v1.first * v2.second - (double)v1.second * v2.first;
      if (v1_cross_v2 <= 0)
        train.pop_back();
      else
        break;
    }
    train.push_back(c);
  };
  for (int z = nquery; z--;) {
    char type;
    std::cin >> type;
    int cnt, b, s;
    switch (type) {
      case '1':
        std::cin >> cnt;
        offset += cnt;
        for (auto c : train) assert(realval(c) >= 0);
        train.clear();
        add_back(0, 0);
        break;
      case '2':
        std::cin >> cnt;
        endpos += cnt;
        add_back(endpos + offset - cnt, 0);
        break;
      case '3':
        std::cin >> b >> s;
        sums += s;
        sumb += s * (int64_t)offset;
        sumb += b;
        while (train.size() >= 2 and
               realval(train.back()) >= realval(train.end()[-2]))
          train.pop_back();
        break;
      default:
        assert(false);
        __builtin_unreachable();
    }
    std::cout << train.back().pos + offset + 1 << ' ' << realval(train.back())
              << '\n';
  }
}
