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;
const int maxn = 1e5 + 10, S1 = 350, S2 = 350;
const long long inf = 4e18;
priority_queue<pair<int, int> > pq;
pair<long long, int> p[maxn], ans[maxn];
bool mark[maxn];
int n;
struct fenwick {
  int sm[maxn], tot;
  fenwick() {
    tot = 0;
    memset(sm, 0, sizeof sm);
  }
  void add(int ind) {
    ind++;
    tot++;
    while (ind < maxn) sm[ind]++, ind += (ind & -ind);
  }
  int ask(int ind) {
    ind = min(ind, maxn - 1);
    int ans = tot;
    while (ind > 0) ans -= sm[ind], ind -= (ind & -ind);
    return ans;
  }
};
fenwick fn;
struct CHT {
  vector<pair<long long, long long> > vec;
  inline long long gety(int ind, long long x) {
    return vec[ind].first * x + vec[ind].second;
  }
  bool bad(pair<long long, long long> A, pair<long long, long long> B,
           pair<long long, long long> C) {
    return (B.second - A.second) * (B.first - C.first) >=
           (B.second - C.second) * (B.first - A.first);
  }
  void add(long long a, long long b) {
    if (int((vec).size()) > 0 && vec.back().first == a) {
      if (b < vec.back().second)
        vec.pop_back();
      else
        return;
    }
    while (int((vec).size()) > 1 &&
           bad(vec[int((vec).size()) - 2], vec[int((vec).size()) - 1], {a, b}))
      vec.pop_back();
    vec.push_back({a, b});
  }
  pair<long long, int> ask(long long x) {
    if (int((vec).size()) == 0) return {inf, -1};
    int l = 0, r = int((vec).size()) - 1;
    long long ans = gety(0, x);
    int ans2 = -vec[0].first;
    while (l < r) {
      int mid = (l + r) >> 1;
      if (gety(mid, x) > gety(mid + 1, x))
        l = mid + 1, ans = gety(mid + 1, x), ans2 = -vec[mid + 1].first;
      else
        r = mid, ans = gety(mid, x), ans2 = -vec[mid].first;
    }
    return {ans, ans2};
  }
};
CHT cht[S2];
void build() {
  for (int i = 0; i < n; i++)
    cht[i / S1].add(-p[i].first, -p[i].first * (n - i));
}
void Delete(int id) {
  mark[id] = 1;
  fn.add(id);
  int sid = id / S1, L = sid * S1, R = L + S1 - 1, cnt = 0;
  cht[sid].vec.clear();
  for (int i = L; i <= R; i++) {
    cnt += mark[i];
  }
  for (int i = L; i <= min(n - 1, R); i++) {
    cnt -= mark[i];
    if (!mark[i]) cht[sid].add(-p[i].first, -p[i].first * (n - i - cnt));
  }
}
pair<long long, int> Ask() {
  pair<long long, int> ans = {-inf, -1};
  for (int i = 0; i < S2; i++) {
    pair<long long, int> P = cht[i].ask(-fn.ask(i * S1 + S1));
    P.first *= -1;
    ans = max(ans, P);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int w, MX = 0;
  cin >> n >> w;
  for (int i = 0; i < n; i++)
    cin >> p[i].first >> p[i].second, MX = max(MX, p[i].second);
  sort(p, p + n);
  for (int i = 0; i < n; i++) pq.push({p[i].second, i});
  build();
  for (int i = MX + 1; i >= 0; i--) {
    while (int((pq).size()) && pq.top().first >= i) {
      Delete(pq.top().second);
      pq.pop();
    }
    pair<long long, int> P = Ask();
    if (P.first == -inf) P = {0, 0};
    ans[i] = {1ll * w * i * (n - int((pq).size())) + P.first, P.second};
  }
  for (int i = 0; i <= MX + 1; i++) {
    cout << ans[i].first << " " << ans[i].second << "\n";
  }
  return 0;
}