Problem: All modern mobile applications are divided into free and paid. Even a single application developers often release two versions: a paid version without ads and a free version with ads.

<image>

Suppose that a paid version of the app costs p (p is an integer) rubles, and the free version of the application contains c ad banners. Each user can be described by two integers: ai — the number of rubles this user is willing to pay for the paid version of the application, and bi — the number of banners he is willing to tolerate in the free version.

The behavior of each member shall be considered strictly deterministic:

  * if for user i, value bi is at least c, then he uses the free version, 
  * otherwise, if value ai is at least p, then he buys the paid version without advertising, 
  * otherwise the user simply does not use the application. 



Each user of the free version brings the profit of c × w rubles. Each user of the paid version brings the profit of p rubles.

Your task is to help the application developers to select the optimal parameters p and c. Namely, knowing all the characteristics of users, for each value of c from 0 to (max bi) + 1 you need to determine the maximum profit from the application and the corresponding parameter p.

Input

The first line contains two integers n and w (1 ≤ n ≤ 105; 1 ≤ w ≤ 105) — the number of users and the profit from a single banner. Each of the next n lines contains two integers ai and bi (0 ≤ ai, bi ≤ 105) — the characteristics of the i-th user.

Output

Print (max bi) + 2 lines, in the i-th line print two integers: pay — the maximum gained profit at c = i - 1, p (0 ≤ p ≤ 109) — the corresponding optimal app cost. If there are multiple optimal solutions, print any of them.

Examples

Input

2 1
2 0
0 2


Output

0 3
3 2
4 2
2 2


Input

3 1
3 1
2 2
1 3


Output

0 4
3 4
7 3
7 2
4 2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const long long MAXN = 100010;
const long long INF = 1e9;
long long N, W;
struct data {
  long long a, b, id;
} q[MAXN + 1], p[MAXN + 1];
struct poi {
  long long x, y;
};
inline poi make_pt(long long x, long long y) {
  poi n;
  n.x = x;
  n.y = y;
  return n;
}
bool cmpA(data a, data b) { return a.a < b.a; }
bool cmpB(data a, data b) { return a.b < b.b; }
long long pos[MAXN + 1];
long long Sqr;
vector<poi> vec[510];
long long Ans[MAXN + 1];
long long ft[MAXN + 1];
inline double Slope(poi a, poi b) { return 1.0 * (a.y - b.y) / (a.x - b.x); }
long long f[MAXN + 1];
long long post[MAXN + 1];
inline void Extend(long long n, long long y, long long x) {
  long long top = vec[n].size();
  if (top && x == vec[n][top - 1].x) return;
  poi P = make_pt(x, y);
  while (top > 1 &&
         Slope(vec[n][top - 1], P) > Slope(vec[n][top - 2], vec[n][top - 1]))
    vec[n].pop_back(), --top;
  vec[n].push_back(P);
}
long long sta[MAXN + 1], top;
long long vis[MAXN + 1];
long long Add[MAXN + 1];
long long bel[MAXN + 1];
long long tim;
inline void build(long long T) {
  vis[N + 1] = T;
  long long num = 0;
  top = 0;
  for (long long i = N; i >= 1; i--) {
    if (vis[i] && vis[i] != T) ++num;
    f[i] = num;
  }
  long long now = 1;
  vec[1].clear();
  ft[1] = 0;
  Add[1] = 0;
  for (long long i = 1; i <= N + 1; i++) {
    bel[i] = now;
    if (vis[i] == T) {
      ++now;
      vec[now].clear();
      ft[now] = 0;
      Add[now] = 0;
      sta[++top] = i, post[i] = top;
      continue;
    }
    if (!vis[i]) continue;
    Extend(now, f[i] * q[i].b, q[i].b);
  }
  return;
}
long long ans = 0, posa = 0;
inline void upd(poi a, long long b) {
  if (a.y + a.x * b > ans) {
    ans = a.y + a.x * b;
    posa = a.x;
  }
  return;
}
bool vis2[MAXN + 1];
long long Posa[MAXN + 1];
int main() {
  N = read(), W = read();
  for (long long i = 1; i <= N; i++) {
    q[i].b = read(), q[i].a = read();
    q[i].id = i;
    p[i] = q[i];
  }
  sort(p + 1, p + N + 1, cmpA);
  sort(q + 1, q + N + 1, cmpB);
  for (long long i = 1; i <= N; i++) pos[q[i].id] = i;
  Sqr = max((long long)ceil(sqrt(N)), 1LL);
  for (long long i = 1; i <= N; i += Sqr) {
    ++tim;
    for (long long j = i; j <= min(i + Sqr - 1, N); j++) {
      vis[pos[p[j].id]] = tim;
    }
    build(tim);
    for (long long j = i; j <= min(i + Sqr - 1, N); j++) {
      long long x = pos[p[j].id];
      vis2[x] = 1;
      for (long long k = post[x]; k >= 1; k--) {
        ++f[sta[k]];
        if (vis2[sta[k]]) {
          if (f[sta[k]] * q[sta[k]].b > ans) {
            ans = f[sta[k]] * q[sta[k]].b;
            posa = q[sta[k]].b;
          }
        }
        long long n = bel[sta[k]];
        ++Add[n];
        while (ft[n] < (long long)vec[n].size() - 1 &&
               Slope(vec[n][ft[n]], vec[n][ft[n] + 1]) >= -Add[n]) {
          upd(vec[n][ft[n]], Add[n]);
          upd(vec[n][ft[n] + 1], Add[n]);
          ++ft[n];
        }
        if (ft[n]) upd(vec[n][ft[n] - 1], Add[n]);
        if (ft[n] < vec[n].size()) upd(vec[n][ft[n]], Add[n]);
        if (ft[n] < (long long)vec[n].size() - 1)
          upd(vec[n][ft[n] + 1], Add[n]);
      }
      Ans[j] = ans;
      Posa[j] = posa;
    }
  }
  long long now = 1;
  for (long long c = 0; c <= p[N].a + 1; c++) {
    while (now <= N && p[now].a < c) ++now;
    printf("%lld %d\n", (N - now + 1) * W * c + Ans[now - 1], Posa[now - 1]);
  }
  return 0;
}