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 mod = 1e9 + 7;
struct fastio {
  char s[100000];
  int it, len;
  fastio() { it = len = 0; }
  inline char get() {
    if (it < len) return s[it++];
    it = 0;
    len = fread(s, 1, 100000, stdin);
    if (len == 0)
      return EOF;
    else
      return s[it++];
  }
  bool notend() {
    char c = get();
    while (c == ' ' || c == '\n') c = get();
    if (it > 0) it--;
    return c != EOF;
  }
} _buff;
inline long long getnum() {
  long long r = 0;
  bool ng = 0;
  char c;
  c = _buff.get();
  while (c != '-' && (c < '0' || c > '9')) c = _buff.get();
  if (c == '-') ng = 1, c = _buff.get();
  while (c >= '0' && c <= '9') r = r * 10 + c - '0', c = _buff.get();
  return ng ? -r : r;
}
template <class T>
inline void putnum(T x) {
  if (x < 0) putchar('-'), x = -x;
  register short a[20] = {}, sz = 0;
  while (x) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
inline char getreal() {
  char c = _buff.get();
  while (c <= 32) c = _buff.get();
  return c;
}
long long qpow(long long x, long long k) {
  return k == 0 ? 1
                : 1ll * qpow(1ll * x * x % mod, k >> 1) * (k & 1 ? x : 1) % mod;
}
struct line {
  long long k, b;
  line(long long K = 0, long long B = 0) : k(K), b(B) {}
  line operator+(const line &t) const { return line(k + t.k, b + t.b); }
  line operator-(const line &t) const { return line(k - t.k, b - t.b); }
  long long get(long long x) { return k * x + b; }
};
long long det(long long ax, long long ay, long long bx, long long by) {
  long double est = 1.0 * ax * by - 1.0 * ay * bx;
  if (est < -1e18) return -1e18;
  if (est > 1e18) return 1e18;
  return ax * by - ay * bx;
}
bool check(pair<long long, line> x, pair<long long, line> y,
           pair<long long, line> z, line lz) {
  x.second = x.second + lz;
  y.second = y.second + lz;
  z.second = z.second + lz;
  long long ax = z.first - x.first;
  long long ay = z.second.get(z.first) - x.second.get(x.first);
  long long bx = y.first - x.first;
  long long by = y.second.get(y.first) - x.second.get(x.first);
  if (det(ax, ay, bx, by) >= 0)
    return true;
  else
    return false;
}
struct Train {
  int n;
  line lz;
  vector<pair<long long, line> > v;
  void clear(int k) {
    v.clear();
    v.push_back(make_pair(0, line(0, 0)));
    n += k;
    lz = line(0, 0);
  }
  void add(int k) {
    v.push_back(make_pair(n, line(0, 0) - lz));
    while (v.size() >= 3) {
      if (check(v[v.size() - 3], v[v.size() - 2], v[v.size() - 1], lz)) {
        swap(v[v.size() - 2], v.back());
        v.pop_back();
      } else
        break;
    }
    n += k;
  }
  void add_line(line l) { lz = lz + l; }
  void query() {
    while (v.size() >= 2) {
      if ((lz + v.back().second).get(v.back().first) >=
          (lz + v[v.size() - 2].second).get(v[v.size() - 2].first))
        v.pop_back();
      else
        break;
    }
    putnum(v.back().first + 1), putchar(' '),
        putnum((v.back().second + lz).get(v.back().first)), putchar('\n');
  }
} T;
int main() {
  int n;
  n = getnum();
  T.clear(n);
  int m;
  m = getnum();
  for (int i = 0; i < m; i++) {
    int ti, k;
    ti = getnum(), k = getnum();
    if (ti == 1)
      T.clear(k);
    else if (ti == 2)
      T.add(k);
    else {
      int b;
      b = getnum();
      T.add_line(line(b, k));
    }
    T.query();
  }
  return 0;
}