Problem: Consider placing N flags on a line. Flags are numbered through 1 to N.

Flag i can be placed on the coordinate X_i or Y_i. For any two different flags, the distance between them should be at least D.

Decide whether it is possible to place all N flags. If it is possible, print such a configulation.

Constraints

* 1 \leq N \leq 1000
* 0 \leq D \leq 10^9
* 0 \leq X_i < Y_i \leq 10^9
* All values in Input are integer.

Input

Input is given from Standard Input in the following format:


N D
X_1 Y_1
X_2 Y_2
\vdots
X_N Y_N


Output

Print `No` if it is impossible to place N flags.

If it is possible, print `Yes` first. After that, print N lines. i-th line of them should contain the coodinate of flag i.

Examples

Input

3 2
1 4
2 5
0 6


Output

Yes
4
2
0


Input

3 3
1 4
2 5
0 6


Output

No

Solution (in CPP):

Solution:
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.08 17:35:29
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;



struct StronglyConnectedComponents {
private:
    vector<vector<int>> g, rg;
    vector<int> order; 
    vector<bool> visited;
    int V;
    void dfs(int v) {
        if (visited[v]) return;
        visited[v] = true;
        for (int u : g[v]) dfs(u);
        order.push_back(v);
    }
    void rdfs(int v, int c) {
        if (comp[v] != -1) return;
        comp[v] = c;
        for (int u : rg[v]) rdfs(u, c);
    }
public:
    vector<vector<int>> Graph; 
    vector<int> comp; 
    StronglyConnectedComponents(int v) : V(v) {
        g.resize(v);
        rg.resize(v);
        visited.resize(v);
        comp.resize(v);
    }
    void add_edge(int from, int to) {
        g[from].push_back(to);
        rg[to].push_back(from);
    }
    void build() {
        Graph = vector<vector<int>>();
        order = vector<int>();
        visited.assign(V, false);
        comp.assign(V, -1);
        for (int i = 0; i < V; i++) dfs(i);
        reverse(order.begin(), order.end());
        int number = 0;
        for (int i = 0; i < V; i++) {
            if (comp[order[i]] == -1) {
                rdfs(order[i], number++);
            }
        }
        Graph.resize(number);
        for (int i = 0; i < V; i++) {
            for (int v : g[i]) {
                if (comp[i] == comp[v]) continue;
                Graph[comp[i]].push_back(comp[v]);
            }
        }
    }
};
int main() {
    int n,d;cin >> n >> d;
    vector<int> x(n),y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    StronglyConnectedComponents scc(2 * n);
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (abs(x[i] - x[j]) < d) {
                scc.add_edge(i,j+n);
                scc.add_edge(j,i+n);
            }
            if (abs(x[i] - y[j]) < d) {
                scc.add_edge(i,j);
                scc.add_edge(j+n,i+n);
            }
            if (abs(y[i] - x[j]) < d) {
                scc.add_edge(i+n,j+n);
                scc.add_edge(j,i);
            }
            if (abs(y[i] - y[j]) < d) {
                scc.add_edge(i+n,j);
                scc.add_edge(j+n,i);
            }
        }
    }
    scc.build();
    bool ok = true;
    vector<int> ans;
    for (int i = 0; i < n; i++) {
        if (scc.comp[i] == scc.comp[i+n]) {
            ok = false;
            break;
        }
        else {
            if (scc.comp[i] > scc.comp[i + n]) {
                ans.push_back(x[i]);
            }
            else {
                ans.push_back(y[i]);
            }
        }
    }
    if (ok) {
        puts("Yes");
        for (int i = 0; i < n; i++) {
            cout << ans[i] << endl;
        }
    }
    else puts("No");
    return 0;
}