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;
using ll = int64_t;
auto& errStream = cerr;
class CerrDummy {
} cerrDummy;
template <class T>
CerrDummy& operator<<(CerrDummy& cd, const T&) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy& cd,
                      basic_ostream<charTDummy, traitsDummy>&(
                          basic_ostream<charTDummy, traitsDummy>&)) {
  return cd;
}
using pi = pair<ll, ll>;
using vi = vector<ll>;
using ld = long double;
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (ll i = ll(0); i < ll((ll)v.size()); i++) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}
template <ll i, class T>
void print_tuple(ostream&, const T&) {}
template <ll i, class T, class H, class... Args>
void print_tuple(ostream& os, const T& t) {
  if (i) os << ",";
  os << get<i>(t);
  print_tuple<i + 1, T, Args...>(os, t);
}
template <class... Args>
ostream& operator<<(ostream& os, const tuple<Args...>& t) {
  os << "(";
  print_tuple<0, tuple<Args...>, Args...>(os, t);
  return os << ")";
}
ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}
void printSpace() { printf(" "); }
void printEoln() { printf("\n"); }
void print(ll x, ll suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}
template <class T>
void print(const vector<T>& v) {
  for (ll i = ll(0); i < ll(v.size()); i++)
    print(v[i], i == ll(v.size()) - 1 ? 1 : 2);
}
string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}
char* readCharArray() {
  static char buf[3341000];
  static ll bufUsed = 0;
  char* ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}
template <class T, class U>
void chmax(T& a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
void chmin(T& a, U b) {
  if (b < a) a = b;
}
template <class T>
T Sq(const T& t) {
  return t * t;
}
void Yes(bool ex = true) {
  cout << "YES" << endl;
  if (ex) exit(0);
}
void No(bool ex = true) {
  cout << "NO" << endl;
  if (ex) exit(0);
}
const ll infLL = LLONG_MAX / 3;
const ll inf = infLL;
constexpr ll Ten(ll n) { return n == 0 ? 1 : Ten(n - 1) * 10; }
template <class T>
vector<T> Uniqued(const vector<T>& vv) {
  auto v(vv);
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}
template <class T>
void MakeUniqued(vector<T>& v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
bool cmpfrac(ll ax, ll ay, ll bx, ll by) {
  ll p = ay / ax, q = by / bx;
  ll r = ay % ax, s = by % bx;
  if (r < 0) {
    p--;
    r += ax;
  }
  if (s < 0) {
    q--;
    s += bx;
  }
  if (p != q) return p < q;
  return r * bx < s * ax;
}
bool cmp(pi a, pi b, pi c) {
  ll ax = b.first - a.first, ay = b.second - a.second;
  ll bx = c.first - b.first, by = c.second - b.second;
  return cmpfrac(ax, ay, bx, by);
}
signed main() {
  ll n = read(), m = read();
  deque<pi> cur;
  cur.push_back(pi(0, 0));
  ll head = 0, tail = n, a = 0, b = 0;
  auto eval = [&](pi x) { return a * x.first + x.second + b; };
  auto cmp2 = [&](pi x, pi y, pi z) {
    return cmp(pi(x.first, eval(x)), pi(y.first, eval(y)),
               pi(z.first, eval(z)));
  };
  for (ll _ = ll(0); _ < ll(m); _++) {
    ll t = read();
    if (t == 1) {
      ll k = read();
      ll x = head - k;
      ll y = -a * x - b;
      while (cur.size() >= 2) {
        if (cmp2(pi(x, y), cur[0], cur[1])) break;
        cur.pop_front();
      }
      cur.push_front(pi(x, y));
      head -= k;
    } else if (t == 2) {
      ll k = read();
      ll x = tail;
      ll y = -a * x - b;
      while (cur.size() >= 2) {
        ll s = cur.size();
        if (cmp2(cur[s - 2], cur[s - 1], pi(x, y))) break;
        cur.pop_back();
      }
      cur.push_back(pi(x, y));
      tail += k;
    } else {
      ll p = read(), q = read();
      a += q;
      b += p - head * q;
    }
    ll s = cur.size();
    ll lw = 0, up = s - 1;
    while (1) {
      const ll m1 = (lw * 2 + up) / 3;
      const ll m2 = (lw + up * 2) / 3;
      if (m1 == m2) break;
      if (eval(cur[m1]) <= eval(cur[m2])) {
        if (up == m2) break;
        up = m2;
      } else {
        if (lw == m1) break;
        lw = m1;
      }
    }
    pi ans(inf, inf);
    for (ll i = ll(lw); i < ll(up + 1); i++) {
      chmin(ans, pi(eval(cur[i]), cur[i].first));
    }
    print(ans.second - head + 1, 2);
    print(ans.first);
  }
}