Problem: Vasya likes to travel by train, but doesn't like when the car he travels in is located in the tail of the train.

Vasya gets on the train at the station. The train consists of n cars indexed from 1 to n counting from the locomotive (head of the train). Three types of events occur while the train is moving:

  1. Some number of cars are added to the head of the train; 
  2. Some number of cars are added to the tail of the train; 
  3. Vasya recalculates the values of the convenience of the cars (read more about it below). 



At each moment of time we will index the cars from the head of the train, starting from 1. Note that when adding new cars to the head of the train, the indexing of the old ones may shift.

To choose which car to go in, Vasya will use the value A_i for each car (where i is a car index), which is calculated as follows:

  * At the beginning of the trip A_i=0, as well as for the new cars at the time of their addition. 
  * During the next recalculation Vasya chooses some positive integers b and s and adds to all A_i value b + (i - 1) ⋅ s. 



Vasya hasn't decided yet where he will get on the train and where will get off the train, so after each event of one of the three types he wants to know the least index of the car, such that its value A_i is minimal. Since there is a lot of cars, Vasya asked you to write a program that answers his question.

Input

The first line contains two integers n and m (1 ≤ n ≤ 10^9, 1 ≤ m ≤ 300 000), the number of cars in the train at the time of departure from the station and the number of stations, respectively.

Next m lines contain the descriptions of events. Each event is one of the following three types:

  * "1 k" (1 ≤ k ≤ 10^9), add k cars to the head of the train 
  * "2 k" (1 ≤ k ≤ 10^9), add k cars to the tail of the train 
  * "3 b s" (1 ≤ b, s ≤ 10^9), recalculate the convenience of all train cars. 



It is guaranteed that at any time the train length does not exceed 10^9. Also it's guaranteed that the integers A_i will not grow too high. Formally, it's guaranteed that if we sum the largest addition over all events of the 3-rd type (that is, b + (n - 1) ⋅ s, where n is the number of cars at that moment) then the acquired sum would be at most 10^{18}.

Output

After each of the m queries print two integers: j and A_j — the number of the car closest to the head of the train, such that its value A_j is minimal, and the value A_j itself.

Example

Input


1 8
1 1
3 1 1
3 1 1
2 1
2 1
3 1 1
2 1
3 1 5


Output


1 0
1 1
1 2
3 0
3 0
1 3
5 0
1 4

Note

  * Initially the train consists of one car with A_1 = 0, let's denote train as [0] for simplicity.
  * After adding one car to the head, train is [0, 0].
  * After recalculation of values with parameters b=1, s=1, train is [1, 2].
  * After another recalculation of values with the parameters b=1, s=1, train is [2, 4].
  * After adding one car to the end, train is [2, 4, 0].
  * After another adding one car to the end, train is [2, 4, 0, 0].
  * After recalculation of values with parameters b=1, s=1, train is [3, 6, 3, 4].
  * After adding one car to the end, train is [3, 6, 3, 4, 0].
  * After recalculation of values with parameters b=1, s=5, train is [4, 12, 14, 20, 21].

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const long long mod = 1e9 + 7;
template <typename T>
struct ConvexHullTrick {
  struct Line {
    T a, b, idx;
    Line(T a = 0, T b = 0, T idx = 0) : a(a), b(b), idx(idx) {}
    pair<long long, long long> get(T x) { return {a * x + b, idx}; }
  };
  struct Node {
    Line l;
    Node *lhs, *rhs;
    Node(Line l) : l(l), lhs(nullptr), rhs(nullptr) {}
  };
  const int n;
  const vector<T> pos;
  Node* root;
  const pair<long long, long long> id = {longinf, longinf};
  ConvexHullTrick(const vector<T>& pos)
      : n(pos.size()), pos(pos), root(nullptr) {}
  Node* insert(Node* p, int lb, int ub, Line& l) {
    if (!p) return new Node(l);
    if (p->l.get(pos[lb]) <= l.get(pos[lb]) &&
        p->l.get(pos[ub]) <= l.get(pos[ub]))
      return p;
    if (p->l.get(pos[lb]) >= l.get(pos[lb]) &&
        p->l.get(pos[ub]) >= l.get(pos[ub])) {
      p->l = l;
      return p;
    }
    int mid = (lb + ub) / 2;
    if (p->l.get(pos[mid]) > l.get(pos[mid])) swap(p->l, l);
    if (p->l.get(pos[lb]) >= l.get(pos[lb])) {
      p->lhs = insert(p->lhs, lb, mid, l);
    } else {
      p->rhs = insert(p->rhs, mid + 1, ub, l);
    }
    return p;
  }
  void insert(T a, T b, T idx) {
    Line l(a, b, idx);
    root = insert(root, 0, n - 1, l);
  }
  pair<long long, long long> query(Node* p, int lb, int ub, int t) {
    if (!p) return id;
    if (lb == ub) return p->l.get(pos[t]);
    int mid = (lb + ub) / 2;
    if (t <= mid)
      return min(p->l.get(pos[t]), query(p->lhs, lb, mid, t));
    else
      return min(p->l.get(pos[t]), query(p->rhs, mid + 1, ub, t));
  }
  pair<long long, long long> query(T x) {
    int t = lower_bound(pos.begin(), pos.end(), x) - pos.begin();
    return query(root, 0, n - 1, t);
  }
};
struct Query {
  long long type, first, second;
};
int main() {
  int n, q;
  cin >> n >> q;
  vector<Query> query(q);
  long long sum = 0;
  vector<long long> S;
  S.push_back(0);
  for (int i = (int)(0); i < (int)(q); ++i) {
    long long type;
    scanf("%lld", &type);
    if (type <= 2) {
      long long l;
      scanf("%lld", &l);
      query[i] = {type, l, 0};
    } else {
      long long b, s;
      scanf("%lld%lld", &b, &s);
      query[i] = {type, b, s};
      sum += s;
      S.push_back(sum);
    }
  }
  ConvexHullTrick<long long> cht(S);
  long long sumb = 0, sums = 0;
  long long lidx = 0, ridx = n;
  cht.insert(0, 0, 0);
  for (auto Q : query) {
    if (Q.type == 1) {
      lidx -= Q.first;
      long long cur = sums * lidx + sumb;
      cht.insert(lidx, -cur, lidx);
    } else if (Q.type == 2) {
      long long cur = sums * ridx + sumb;
      cht.insert(ridx, -cur, ridx);
      ridx += Q.first;
    } else {
      Q.first -= Q.second * lidx;
      sumb += Q.first;
      sums += Q.second;
    }
    auto ret = cht.query(sums);
    printf("%lld %lld\n", ret.second - lidx + 1, ret.first + sumb);
  }
  return 0;
}