#line 2 "cpplib/util/template.hpp"
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#include<bits/stdc++.h>
using namespace std;
struct __INIT__{__INIT__(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}__INIT__;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define endl ('\n')
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,...) for(auto i:range(__VA_ARGS__)) 
#define rrep(i,...) for(auto i:reversed(range(__VA_ARGS__)))
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
inline vector<long long> range(long long n){if(n<=0)return vector<long long>();vector<long long>v(n);iota(v.begin(),v.end(),0LL);return v;}
inline vector<long long> range(long long a,long long b){if(b<=a)return vector<long long>();vector<long long>v(b-a);iota(v.begin(),v.end(),a);return v;}
inline vector<long long> range(long long a,long long b,long long c){if((b-a+c-1)/c<=0)return vector<long long>();vector<long long>v((b-a+c-1)/c);for(int i=0;i<(int)v.size();++i)v[i]=i?v[i-1]+c:a;return v;}
template<typename T>inline T reversed(T v){reverse(v.begin(),v.end());return v;}
#define all(n) begin(n),end(n)
template<typename T,typename E>bool chmin(T& s,const E& t){bool res=s>t;s=min<T>(s,t);return res;}
template<typename T,typename E>bool chmax(T& s,const E& t){bool res=s<t;s=max<T>(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
template<typename T,typename ...Args>auto make_vector(T x,int arg,Args ...args){if constexpr(sizeof...(args)==0)return vector<T>(arg,x);else return vector(arg,make_vector<T>(x,args...));}
#line 5 "cpplib/graph_tree/graph_template.hpp"
/**
 * @brief グラフテンプレート
 */

using graph=std::vector<std::vector<int>>;
template<typename T>
using graph_w=std::vector<std::vector<std::pair<int,T>>>;

graph load_graph(int n,int m){
    graph g(n);
    for(int i=0;i<m;++i){
        int s,t;
        std::cin>>s>>t;
        --s;--t;
        g[s].push_back(t);
        g[t].push_back(s);
    }
    return g;
}
graph load_digraph(int n,int m){
    graph g(n);
    for(int i=0;i<m;++i){
        int s,t;
        std::cin>>s>>t;
        --s;--t;
        g[s].push_back(t);
    }
    return g;
}
graph load_graph0(int n,int m){
    graph g(n);
    for(int i=0;i<m;++i){
        int s,t;
        std::cin>>s>>t;
        g[s].push_back(t);
        g[t].push_back(s);
    }
    return g;
}
graph load_digraph0(int n,int m){
    graph g(n);
    for(int i=0;i<m;++i){
        int s,t;
        std::cin>>s>>t;
        g[s].push_back(t);
    }
    return g;
}
graph load_tree(int n){
    graph g(n);
    for(int i=0;i<n-1;++i){
        int s,t;
        std::cin>>s>>t;
        --s;--t;
        g[s].push_back(t);
        g[t].push_back(s);
    }
    return g;
}
graph load_tree0(int n){
    graph g(n);
    for(int i=0;i<n-1;++i){
        int s,t;
        std::cin>>s>>t;
        g[s].push_back(t);
        g[t].push_back(s);
    }
    return g;
}
graph load_treep(int n){
    graph g(n);
    for(int i=0;i<n-1;++i){
        int t;
        std::cin>>t;
        g[i+1].push_back(t);
        g[t].push_back(i+1);
    }
    return g;
}

template<typename T>
graph_w<T> load_graph_weight(int n,int m){
    graph_w<T> g(n);
    for(int i=0;i<m;++i){
        int s,t;
        T u;
        std::cin>>s>>t>>u;
        --s;--t;
        g[s].emplace_back(t,u);
        g[t].emplace_back(s,u);
    }
    return g;
}
template<typename T>
graph_w<T> load_digraph_weight(int n,int m){
    graph_w<T> g(n);
    for(int i=0;i<m;++i){
        int s,t;
        T u;
        std::cin>>s>>t>>u;
        --s;--t;
        g[s].emplace_back(t,u);
    }
    return g;
}
template<typename T>
graph_w<T> load_graph0_weight(int n,int m){
    graph_w<T> g(n);
    for(int i=0;i<m;++i){
        int s,t;
        T u;
        std::cin>>s>>t>>u;
        g[s].emplace_back(t,u);
        g[t].emplace_back(s,u);
    }
    return g;
}
template<typename T>
graph_w<T> load_digraph0_weight(int n,int m){
    graph_w<T> g(n);
    for(int i=0;i<m;++i){
        int s,t;
        T u;
        std::cin>>s>>t>>u;
        g[s].emplace_back(t,u);
    }
    return g;
}
template<typename T>
graph_w<T> load_tree_weight(int n){
    graph_w<T> g(n);
    for(int i=0;i<n-1;++i){
        int s,t;
        T u;
        std::cin>>s>>t>>u;
        --s;--t;
        g[s].emplace_back(t,u);
        g[t].emplace_back(s,u);
    }
    return g;
}
template<typename T>
graph_w<T> load_tree0_weight(int n){
    graph_w<T> g(n);
    for(int i=0;i<n-1;++i){
        int s,t;
        T u;
        std::cin>>s>>t>>u;
        g[s].emplace_back(t,u);
        g[t].emplace_back(s,u);
    }
    return g;
}
template<typename T>
graph_w<T> load_treep_weight(int n){
    graph_w<T> g(n);
    for(int i=0;i<n-1;++i){
        int t;
        T u;
        std::cin>>t>>u;
        g[i+1].emplace_back(t,u);
        g[t].emplace_back(i+1,u);
    }
    return g;
}
#line 2 "code.cpp"


#include <algorithm>
#include <utility>
#include <vector>

namespace atcoder {
namespace internal {

template <class E> struct csr {
    std::vector<int> start;
    std::vector<E> elist;
    csr(int n, const std::vector<std::pair<int, E>>& edges)
        : start(n + 1), elist(edges.size()) {
        for (auto e : edges) {
            start[e.first + 1]++;
        }
        for (int i = 1; i <= n; i++) {
            start[i] += start[i - 1];
        }
        auto counter = start;
        for (auto e : edges) {
            elist[counter[e.first]++] = e.second;
        }
    }
};

// Reference:
// R. Tarjan,
// Depth-First Search and Linear Graph Algorithms
struct scc_graph {
  public:
    scc_graph(int n) : _n(n) {}

    int num_vertices() { return _n; }

    void add_edge(int from, int to) { edges.push_back({from, {to}}); }

    // @return pair of (# of scc, scc id)
    std::pair<int, std::vector<int>> scc_ids() {
        auto g = csr<edge>(_n, edges);
        int now_ord = 0, group_num = 0;
        std::vector<int> visited, low(_n), ord(_n, -1), ids(_n);
        visited.reserve(_n);
        auto dfs = [&](auto self, int v) -> void {
            low[v] = ord[v] = now_ord++;
            visited.push_back(v);
            for (int i = g.start[v]; i < g.start[v + 1]; i++) {
                auto to = g.elist[i].to;
                if (ord[to] == -1) {
                    self(self, to);
                    low[v] = std::min(low[v], low[to]);
                } else {
                    low[v] = std::min(low[v], ord[to]);
                }
            }
            if (low[v] == ord[v]) {
                while (true) {
                    int u = visited.back();
                    visited.pop_back();
                    ord[u] = _n;
                    ids[u] = group_num;
                    if (u == v) break;
                }
                group_num++;
            }
        };
        for (int i = 0; i < _n; i++) {
            if (ord[i] == -1) dfs(dfs, i);
        }
        for (auto& x : ids) {
            x = group_num - 1 - x;
        }
        return {group_num, ids};
    }

    std::vector<std::vector<int>> scc() {
        auto ids = scc_ids();
        int group_num = ids.first;
        std::vector<int> counts(group_num);
        for (auto x : ids.second) counts[x]++;
        std::vector<std::vector<int>> groups(ids.first);
        for (int i = 0; i < group_num; i++) {
            groups[i].reserve(counts[i]);
        }
        for (int i = 0; i < _n; i++) {
            groups[ids.second[i]].push_back(i);
        }
        return groups;
    }

  private:
    int _n;
    struct edge {
        int to;
    };
    std::vector<std::pair<int, edge>> edges;
};

}  // namespace internal

}  // namespace atcoder

#include <cassert>
#include <vector>

namespace atcoder {

// Reference:
// B. Aspvall, M. Plass, and R. Tarjan,
// A Linear-Time Algorithm for Testing the Truth of Certain Quantified Boolean
// Formulas
struct two_sat {
  public:
    two_sat() : _n(0), scc(0) {}
    two_sat(int n) : _n(n), _answer(n), scc(2 * n) {}

    void add_clause(int i, bool f, int j, bool g) {
        assert(0 <= i && i < _n);
        assert(0 <= j && j < _n);
        scc.add_edge(2 * i + (f ? 0 : 1), 2 * j + (g ? 1 : 0));
        scc.add_edge(2 * j + (g ? 0 : 1), 2 * i + (f ? 1 : 0));
    }
    bool satisfiable() {
        auto id = scc.scc_ids().second;
        for (int i = 0; i < _n; i++) {
            if (id[2 * i] == id[2 * i + 1]) return false;
            _answer[i] = id[2 * i] < id[2 * i + 1];
        }
        return true;
    }
    std::vector<bool> answer() { return _answer; }

  private:
    int _n;
    std::vector<bool> _answer;
    internal::scc_graph scc;
};

}  // namespace atcoder

using namespace atcoder;

int main(){
    lint n,d;
    cin>>n>>d;
    auto g=two_sat(n);
    vec x(n),y(n);
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    rep(i,n)rep(j,i){
        if(abs(x[i]-x[j])<d){
            g.add_clause(i,0,j,0);
        }
        if(abs(x[i]-y[j])<d){
            g.add_clause(i,0,j,1);
        }
        if(abs(y[i]-x[j])<d){
            g.add_clause(i,1,j,0);
        }
        if(abs(y[i]-y[j])<d){
            g.add_clause(i,1,j,1);
        }
    }
    if(g.satisfiable()==0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
        auto e=g.answer();
        rep(i,n){
            if(e[i])cout<<x[i]<<endl;
            else cout<<y[i]<<endl;
        }
    }
}


Measured memory_bytes: 3780