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;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

class strong_components{
private:
    vector<vector<int>> v,rv,nv;
    vector<int> rs,visited,cmp,cmp_size;
    void dfs(int n){
        visited[n] = 1;
        for(auto x:v[n]) if(!visited[x]) dfs(x);
        rs.push_back(n);
    }
    void rdfs(int n,int cnt){
        visited[n] = 1;
        cmp[n] = cnt;
        for(auto x:rv[n]) if(!visited[x]) rdfs(x,cnt);
    }
public:
    strong_components(int N,vector<vector<int>>& graph){
        v = graph;
        rv = vector<vector<int>>(N);
        visited = cmp = cmp_size = vector<int>(N,0);
        for(int i=0;i<N;i++) for(auto x:v[i]) rv[x].push_back(i);
        for(int i=0;i<N;i++) if(!visited[i]) dfs(i);
        for(int i=0;i<N;i++) visited[i] = 0;
        int now = 0;
        for(int i=(int) rs.size()-1;i>=0;i--) if(!visited[rs[i]]) rdfs(rs[i],now++);
        nv = vector<vector<int>>(now);
        for(int i=0;i<N;i++){
            for(auto x:v[i]){
                if(cmp[i]!=cmp[x]){
                    nv[cmp[i]].push_back(cmp[x]);
                    cmp_size[cmp[x]]++;
                }
            }
        }
    }
    int find(int n){return cmp[n];}
    bool is_same_group(int a,int b){return cmp[a]==cmp[b];}
};

class SAT{
private:
    int N;
    vector<vector<int>> v;
public:
    SAT(int N):N(N){
        v = vector<vector<int>>(2*N);
    }
    void add_closure(int x, bool bx, int y, bool by){
        v[x+(!bx)*N].push_back(y+by*N);
        v[y+(!by)*N].push_back(x+bx*N);
    }
    vector<int> solve(){
        strong_components scc(2*N,v);
        //不可能か判定
        vector<int> res(N);
        for(int i=0;i<N;i++){
            //同じ強連結成分にあったらだめ
            if(scc.is_same_group(i,i+N)) return vector<int> {};
            res[i] = (scc.find(i)<scc.find(i+N));
        }
        return res;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,D;
    cin >> N >> D;
    vec<int> X(N),Y(N);
    for(int i=0;i<N;i++) cin >> X[i] >> Y[i];
    SAT sat(N);
    for(int i=0;i<N;i++) for(int j=i+1;j<N;j++){
        if(abs(X[i]-X[j])<D) sat.add_closure(i,false,j,false);
        if(abs(X[i]-Y[j])<D) sat.add_closure(i,false,j,true);
        if(abs(Y[i]-X[j])<D) sat.add_closure(i,true,j,false);
        if(abs(Y[i]-Y[j])<D) sat.add_closure(i,true,j,true);
    }
    auto res = sat.solve();
    if(res.empty()){
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    for(int i=0;i<N;i++) cout << (res[i]? X[i]:Y[i]) << "\n";
}