#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

struct SCC{
private:
    int V;
    vector<vector<int>> G, rG;
    vector<bool> used;
    vector<int> pos;
public:
    SCC(int _V=0){
        V = _V;
        G.resize(V);
        rG.resize(V);
    }
    void init(int _V){
        V = _V;
        G.resize(V);
        rG.resize(V);
    }
    void add(int from, int to){
        G[from].push_back(to);
        rG[to].push_back(from);
    }
    void dfs(int v){
        used[v] = true;
        for(int i=0; i<G[v].size(); i++){
            if(!used[G[v][i]]) dfs(G[v][i]);
        }
        pos.push_back(v);
    }
    void rdfs(int v, vector<int>& ls){
        used[v] = true;
        ls.push_back(v);
        for(int i=0; i<rG[v].size(); i++){
            if(!used[rG[v][i]]) rdfs(rG[v][i], ls);
        }
    }
    vector<vector<int>> scc(){
        pos.clear();
        used.clear();
        used.resize(V, false);
        for(int i=0; i<V; i++){
            if(!used[i]) dfs(i);
        }
        used.clear();
        used.resize(V, false);
        vector<vector<int>> ret;
        for(int i=V-1; i>=0; i--){
            if(!used[pos[i]]){
                ret.push_back(vector<int>());
                rdfs(pos[i], ret.back());
            }
        }
        return ret;
    }
};

struct TWO_SAT{
private:
    int N;
    SCC s;
    vector<bool> ans;
public:
    TWO_SAT(int _N=0){
        N = _N;
        s.init(2*N);
    }
    void init(int _N){
        N = _N;
        s.init(2*N);
    }
    void add(int i, bool bi, int j, bool bj){
        if(!bi) i = N + i;
        if(!bj) j = N + j;
        s.add((i+N)%(2*N), j);
        s.add((j+N)%(2*N), i);
    }
    bool satisfiable(){
        auto v = s.scc();
        vector<int> cmp(2*N);
        for(int i=0; i<v.size(); i++){
            for(int j=0; j<v[i].size(); j++){
                cmp[v[i][j]] = i;
            }
        }
        ans = vector<bool>(N, false);
        for(int i=0; i<N; i++){
            if(cmp[i] == cmp[N+i]) return false;
            ans[i] = (cmp[i] > cmp[N+i]);
        }
        return true;
    }
    vector<bool> answer(){
        return ans;
    }
};

int N, D;
int X[1000], Y[1000];
vector<pair<int,pair<int,bool>>> v;
TWO_SAT ts;

signed main(){
    cin >> N >> D;
    rep(i, N){
        cin >> X[i] >> Y[i];
    }
    sort(all(v));
    ts.init(N);
    rep(i, N){
        rep(j, N){
            if(i == j) continue;
            if(abs(X[i]-X[j]) < D) ts.add(i, true, j, true);
            if(abs(X[i]-Y[j]) < D) ts.add(i, true, j, false);
            if(abs(Y[i]-X[j]) < D) ts.add(i, false, j, true);
            if(abs(Y[i]-Y[j]) < D) ts.add(i, false, j, false);
        }
    }
    if(ts.satisfiable()){
        cout << "Yes" << endl;
        auto ans = ts.answer();
        rep(i, N) cout << (!ans[i] ? X[i] : Y[i]) << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3932