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 int Read() {
  char c = getchar();
  int num = 0;
  while ('0' > c || c > '9') c = getchar();
  while ('0' <= c && c <= '9') num = num * 10 + c - '0', c = getchar();
  return (num);
}
int wr[20], wt;
inline void Write(long long x) {
  if (!x) {
    putchar('0');
    return;
  }
  for (; x; x /= 10) wr[++wt] = x % 10;
  for (; wt; wt--) putchar('0' + wr[wt]);
  ;
}
struct seg {
  int k, b;
  double l;
} g[510][510], e[510][510];
struct ppp {
  int x, y, id;
} a[120000];
int total[120000], size[120000], be[120000], pot[120000], S, n, w, i,
    pos[120000], nn, j;
long long fans[120000][2];
bool cmp1(const ppp &a, const ppp &b) { return a.x < b.x; }
bool cmp2(const ppp &a, const ppp &b) { return a.y < b.y; }
double jiao(seg &a, seg &b) { return ((double)b.b - a.b) / (a.k - b.k); }
void build(int v) {
  int tot = 0;
  for (int i = 1; i <= size[v]; ++i) {
    if (i != 1 && e[v][i].k == e[v][i - 1].k) continue;
    while (tot > 0 && jiao(g[v][tot], e[v][i]) < g[v][tot].l) tot--;
    g[v][++tot] = e[v][i];
    g[v][tot].l = (tot == 1 ? -1e9 : jiao(g[v][tot], g[v][tot - 1]));
  }
  g[v][tot + 1].l = 1e9;
}
void add(ppp a) {
  int v = be[pos[a.id]], i, j;
  e[v][++size[v]] = (seg){a.x, 0, 0};
  i = size[v];
  while (i - 1 >= 1 && e[v][i].k < e[v][i - 1].k) {
    swap(e[v][i - 1], e[v][i]);
    i--;
  }
  for (j = 1; j < i; ++j) e[v][j].b += e[v][j].k;
  e[v][i].b = e[v][i].k * (size[v] - i + 1);
  build(v);
  pot[v] = 1;
  for (i = 1; i <= v; ++i) {
    if (i < v) total[i]++;
    if (size[i])
      while (total[i] > g[i][pot[i] + 1].l) pot[i]++;
  }
}
void query(int x) {
  long long ans = 0;
  for (int i = 1; i <= S; ++i)
    if (size[i]) {
      long long tmp = g[i][pot[i]].b + 1ll * g[i][pot[i]].k * total[i];
      if (tmp > ans) {
        ans = tmp;
        fans[x][1] = g[i][pot[i]].k;
      }
    }
  fans[x][0] = ans;
}
int main() {
  scanf("%d%d", &n, &w);
  for (i = 1; i <= n; ++i) a[i].x = Read(), a[i].y = Read(), a[i].id = i;
  sort(a + 1, a + n + 1, cmp1);
  for (i = 1; i <= n; ++i) pos[a[i].id] = i;
  sort(a + 1, a + n + 1, cmp2);
  nn = max(1, (int)sqrt(n));
  for (i = 1; i <= n; ++i) be[i] = (i - 1) / nn + 1;
  S = be[n];
  j = 1;
  for (i = 0; i <= a[n].y + 1; ++i) {
    while (j <= n && a[j].y < i) {
      add(a[j]);
      j++;
    }
    query(i);
    fans[i][0] += 1ll * (n - j + 1) * i * w;
  }
  for (i = 0; i <= a[n].y + 1; ++i) {
    Write(fans[i][0]), putchar(' '), Write(fans[i][1]), puts("");
  }
}