#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
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; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

// 強連結成分分解
class SCC {
    public:
        friend class TwoSat;
        SCC() {}
        SCC(int v) { Init(v); }
        void Init(int v) {
            m_V = v;
            m_G.assign(v, vector<int>());
            m_Rg.assign(v, vector<int>());
            m_Used.assign(v, false);
            m_Cmp.assign(v, 0);
        }
        void AddEdge(int from, int to) {
            m_G[from].push_back(to);
            m_Rg[to].push_back(from);
        }
        int Scc() {
            m_Used.assign(m_V, false);
            m_Vs.clear();
            for(int v = 0; v < m_V; ++v) {
                if(!m_Used[v]) { Dfs(v); }
            }
            m_Used.assign(m_V, false);
            int k = 0;
            for(int i = int(m_Vs.size() - 1); i >= 0; --i) {
                if(!m_Used[m_Vs[i]]) { Rdfs(m_Vs[i], k++); }
            }
            return k;
        }
    private:
        void Dfs(int v) {
            m_Used[v] = true;
            for(int i = 0; i < int(m_G[v].size()); ++i) {
                if(!m_Used[m_G[v][i]]) { Dfs(m_G[v][i]); }
            }
            m_Vs.push_back(v);
        }
        void Rdfs(int v, int k) {
            m_Used[v] = true;
            m_Cmp[v] = k;
            for(int i = 0; i < int(m_Rg[v].size()); ++i) {
                if(!m_Used[m_Rg[v][i]]) { Rdfs(m_Rg[v][i], k); }
            }
        }
    private:
        int m_V;                    // 頂点数
        vector< vector<int> >  m_G; // グラフの隣接リスト表現
        vector< vector<int> > m_Rg; // 辺の向きが逆のグラフ
        vector<int> m_Vs;           // 帰りがけ順の並び
        vector<bool> m_Used;        // すでに調べたか
        vector<int> m_Cmp;          // 属する強連結成分のトポロジカル順序
};

class TwoSat {
    public:
        friend class SCC;
        TwoSat() {}
        TwoSat(int v) { Init(v); }
        void Init(int v) {
            m_V = v;
            m_Scc.Init(m_V * 2);
        }
        void AddClause(int i, bool f, int j, bool g) {
            int i_n = (f) ? i : (i + m_V);
            int i_i = (f) ? (i + m_V) : i;
            int j_n = (g) ? j : (j + m_V);
            int j_i = (g) ? (j + m_V) : j;
            m_Scc.AddEdge(i_i, j_n);
            m_Scc.AddEdge(j_i, i_n);
        }
        bool Satisfiable() {
            m_Scc.Scc();
            for(int i = 0; i < m_V; ++i) {
                if(m_Scc.m_Cmp[i] == m_Scc.m_Cmp[i + m_V]) {
                    return false;
                }
            }
            return true;
        }
        vector<bool> Answer() {
            vector<bool> ret(m_V, false);
            for(int i = 0; i < m_V; ++i) {
                if(m_Scc.m_Cmp[i] > m_Scc.m_Cmp[i + m_V]) {
                    ret[i] = true;
                }
            }
            return ret;
        }
    private:
        int m_V;
        SCC m_Scc;
};

const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
    IOS;

    int N, D;
    cin >> N >> D;
    V<> X(N), Y(N);
    REP(i, N) {
        cin >> X[i] >> Y[i];
    }
    TwoSat ts(N);
    // X を選択 := true
    // Y を選択 := false
    REP(i, N) {
        for(int j = i + 1; j < N; ++j) {
            //if(i == j) { continue; }
            if(abs(X[i] - X[j]) < D) {
                // この 2 つは共存できない(両方 X はダメ)
                // -> どちらか 1 つは必ず Y を選ばなければならない
                ts.AddClause(i, false, j, false);
            }
            if(abs(X[i] - Y[j]) < D) {
                ts.AddClause(i, false, j, true);
            }
            if(abs(Y[i] - X[j]) < D) {
                ts.AddClause(i, true, j, false);
            }
            if(abs(Y[i] - Y[j]) < D) {
                ts.AddClause(i, true, j, true);
            }
        }
    }
    if(ts.Satisfiable()) {
        Yes(true);
        auto ans = ts.Answer();
        REP(i, N) {
            if(ans[i]) {
                print(X[i]);
            }
            else {
                print(Y[i]);
            }
        }
    }
    else {
        Yes(false);
    }


    return 0;
}


Measured memory_bytes: 3924