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
#include <bits/stdc++.h>
using namespace std;
struct pp {
  long long a, b;
} p[1000005];
bool cmpb(const pp &i, const pp &j) { return i.b < j.b; }
long long n, w, maxb, st[400][400], add[1000005], maxid[400], ans, ansid, maxa,
    a[1000005];
long long wz(long long x) { return (x - 1) / 300 + 1; }
long long sz(long long x) {
  if (x != wz(maxa))
    return 300;
  else
    return maxa - (x - 1) * 300;
}
bool goleft(long long s) {
  long long xa = st[s][st[s][0] - 1] - st[s][st[s][0] - 2];
  long long ya = a[st[s][st[s][0] - 1]] - a[st[s][st[s][0] - 2]];
  long long xb = st[s][st[s][0]] - st[s][st[s][0] - 1];
  long long yb = a[st[s][st[s][0]]] - a[st[s][st[s][0] - 1]];
  if (xa * yb - xb * ya >= 0)
    return 1;
  else
    return 0;
}
int main() {
  scanf("%I64d%I64d", &n, &w);
  for (long long i = 1; i <= n; i++) {
    scanf("%I64d%I64d", &p[i].a, &p[i].b);
    maxb = max(maxb, p[i].b);
    maxa = max(maxa, p[i].a);
  }
  sort(p + 1, p + n + 1, cmpb);
  long long now = 1, bignum = n;
  for (long long i = 1; i <= maxa; i++) st[wz(i)][++st[wz(i)][0]] = i;
  for (long long i = 1; i <= wz(maxa); i++) maxid[i] = 1;
  for (long long ii = 0; ii <= maxb + 1; ii++) {
    while (p[now].b < ii && now <= n) {
      long long s = wz(p[now].a);
      for (long long i = 1; i < s; i++) {
        add[i]++;
        while (add[i] * st[i][maxid[i]] + a[st[i][maxid[i]]] <=
                   add[i] * st[i][maxid[i] + 1] + a[st[i][maxid[i] + 1]] &&
               maxid[i] < st[i][0])
          maxid[i]++;
      }
      for (long long i = (s - 1) * 300 + 1; i <= (s - 1) * 300 + sz(s); i++)
        a[i] += i * add[s];
      for (long long i = (s - 1) * 300 + 1; i <= p[now].a; i++) a[i] += i;
      st[s][0] = 0;
      for (long long i = (s - 1) * 300 + 1; i <= (s - 1) * 300 + sz(s); i++) {
        st[s][++st[s][0]] = i;
        if (st[s][0] > 2)
          while (goleft(s)) {
            st[s][st[s][0] - 1] = st[s][st[s][0]];
            st[s][0]--;
            if (st[s][0] <= 2) break;
          }
      }
      long long td = 0;
      for (long long i = 1; i <= st[s][0]; i++)
        if (a[st[s][i]] > td) {
          td = a[st[s][i]];
          maxid[s] = i;
        }
      add[s] = 0;
      bignum--;
      now++;
    }
    ans = ansid = 0;
    for (long long i = 1; i <= wz(maxa); i++) {
      if (a[st[i][maxid[i]]] + add[i] * st[i][maxid[i]] > ans) {
        ans = a[st[i][maxid[i]]] + add[i] * st[i][maxid[i]];
        ansid = st[i][maxid[i]];
      }
    }
    printf("%I64d %I64d\n", ans + bignum * ii * w, ansid);
  }
}
