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:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct Graph{
    vector<vector<int>> es;
    const int n;

    Graph(int n) : n(n){
        es.resize(n);
    }

    void add_edge(int from, int to, bool directed = false){
        es[from].pb(to);
        if(!directed) es[to].pb(from);
    }
};

struct Strongly_Connected_Components{
    vector<vector<int>> es, rs;
    vector<int> vs, comp;
    vector<bool> used;
    const int n;

    Strongly_Connected_Components(int n) : n(n){
        es.resize(n), rs.resize(n);
        vs.resize(n), comp.resize(n), used.resize(n);
    }

    void add_edge(int from, int to, bool directed = true){
        es[from].pb(to), rs[to].pb(from);
        if(!directed) es[to].pb(from), rs[from].pb(to);
    }

    void dfs(int now){
        used[now] = true;
        for(auto &e: es[now]) if(!used[e]) dfs(e);
        vs.pb(now);
    }

    void rdfs(int now, int cnt){
        used[now] = true, comp[now] = cnt;
        for(auto &e: rs[now]) if(!used[e]) rdfs(e, cnt);
    }

    Graph decompose(){
        fill(all(used), false);
        rep(i, n) if(!used[i]) dfs(i);
        fill(all(used), false), reverse(all(vs));
        int cnt = 0;
        for(auto &e: vs) if(!used[e]) rdfs(e, cnt++);
        Graph G(cnt);
        rep(i, n){
            for(auto &e: es[i]){
                int u = comp[i], v = comp[e];
                if(u != v) G.add_edge(u, v, true);
            }
        }
        return G;
    }

    int operator [] (int k) const {return comp[k];}
};

int main(){
    int N, D;
    cin >> N >> D;
    int x[N], y[N];
    rep(i, N) cin >> x[i] >> y[i];
    Strongly_Connected_Components G(2*N);
    rep(i, N){
        rep(j, i){
            if(abs(x[i]-x[j]) < D) G.add_edge(i, N+j), G.add_edge(j, N+i);
            if(abs(x[i]-y[j]) < D) G.add_edge(i, j), G.add_edge(N+j, N+i);
            if(abs(y[i]-x[j]) < D) G.add_edge(N+i, N+j), G.add_edge(j, i);
            if(abs(y[i]-y[j]) < D) G.add_edge(N+i, j), G.add_edge(N+j, i);
        }
    }
    G.decompose();
    int ans[N];
    rep(i, N){
        if(G[i] == G[N+i]) {cout << "No" << endl; return 0;}
        if(G[i] > G[N+i]) ans[i] = x[i];
        if(G[i] < G[N+i]) ans[i] = y[i];
    }
    cout << "Yes" << endl;
    rep(i, N) cout << ans[i] << endl;
}