#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring>
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));
template<typename T>
struct SCC{
    T &G;
    vector<vector<int>> Ngraph,Rgraph;
    vector<int> comp,order;
    vector<bool> used;
    SCC(T &g):G(g),Ngraph((int)g.size()),Rgraph((int)g.size()),comp((int)g.size(),-1),used((int)g.size()){
        for(int i=0;i<(int)g.size();i++){
            for(auto to:g[i]){
                Ngraph[i].push_back((int)to);
                Rgraph[(int)to].push_back(i);
            }
        }
    }
    int operator[](int idx){
        //assert(0<=idx&&idx<comp.size());
        return comp[idx];
    }
    void dfs(int idx){
        if(used[idx]) return;
        used[idx]=true;
        for(auto &to:Ngraph[idx]) dfs(to);
        order.push_back(idx);
    }
    void rdfs(int idx,int cnt){
        if(comp[idx]!=-1) return;
        comp[idx]=cnt;
        for(auto &to:Rgraph[idx]) rdfs(to,cnt);
    }
    void build(vector<vector<int>> &ret){
        for(int i=0;i<(int)Ngraph.size();i++) dfs(i);
        reverse(order.begin(),order.end());
        int group=0;
        for(auto i:order){
            if(comp[i]==-1){
                rdfs(i,group);
                group++;
            }
        }
        ret.resize(group);
        for(int i=0;i<(int)G.size();i++){
            for(auto &to:G[i]){
                int s=comp[i],t=comp[to];
                if(s!=t) ret[s].push_back(t);
            }
        }
    }
};
struct two_sat{
private:
    int _n;
    vector<bool> _answer;
    vector<vector<int>> _v;
public:
    two_sat():_n(0){}
    two_sat(vector<vector<int>> &v):_n((int)v.size()),_answer((int)v.size()),_v(v){}
    bool satisfiable(){
        vector<vector<int>> hoge;
        SCC<vector<vector<int>>> scc(_v);
        scc.build(hoge);
        for(int i=0;2*i+1<_n;i++){
            //assert(2*i+1<scc.comp.size());
            if(scc[2*i]==scc[2*i+1]) return false;
            _answer[i] = scc[2*i] < scc[2*i+1];
        }
        return true;
    }
    vector<bool> answer(){
        return _answer;
    }
};

signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int n,d; cin >> n >> d;
    vector<int> x(n),y(n);
    rep(i,n) cin >> x[i] >> y[i];
    vector<vector<int>> v(2*n);
    auto add_E=[&](int x_i,bool x_f,int x_j,bool x_g){
        //cout << "DEEEEEN" << endl;
        v[2*x_i+(x_f?0:1)].push_back(2*x_j+(x_g?1:0));
        v[2*x_j+(x_g?0:1)].push_back(2*x_i+(x_f?1:0));
    };
    rep(i,n){
        for(int j=i+1;j<n;j++){
            if (abs(x[i] - x[j]) < d) {
                add_E(i,false,j,false);
            }
            if (abs(x[i] - y[j]) < d) {
                add_E(i,false,j,true);
            }
            if (abs(y[i] - x[j]) < d) {
                add_E(i,true,j,false);
            }
            if (abs(y[i] - y[j]) < d) {
                add_E(i,true,j,true);
            }
        }
    }
    //rep(i,2*n) cout << v[i].size() << " ";
    two_sat ts(v);
    if(!ts.satisfiable()){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        vector<bool> as=ts.answer();
        rep(i,n){
            cout << (as[i]?x[i]:y[i]) << "\n";
        }
    }
}




Measured memory_bytes: 4104