#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct StrongConnectedComponent {
  ll size, size_scc;
  vector<vector<ll>> adj, radj, adj_scc, vertex_set;
  vector<ll> vertex, vertex_scc, topo;
  StrongConnectedComponent(ll N) {
    size = N; 
    adj.resize(N); radj.resize(N);
    vertex.resize(N); rep(i,N) vertex[i] = i;
  }
  void add_edge(ll from, ll to) { 
    adj[from].push_back(to);
    radj[to].push_back(from);
  }
  void dfs_std(ll n, ll &o, vector<ll> &order) {
    if (order[n]!=-1) return;
    order[n] = LLINF;
    for (auto x: adj[n]) if (order[x]==-1) dfs_std(x,o,order);
    order[n] = o; o--;
  }
  void dfs_rev(ll n, ll v, vector<ll> &vid) {
    vid[n] = v;
    for (auto x: radj[n]) if (vid[x]==-1) dfs_rev(x,v,vid);
  }
  void restruct(ll v, vector<ll> &vid) {
    size_scc = v;
    adj_scc.resize(v); vertex_scc.resize(v,0); vertex_set.resize(v);
    rep(i,size) {
      for (auto x: adj[i]) if (vid[i]!=vid[x]) adj_scc[vid[i]].push_back(vid[x]);
      vertex_scc[vid[i]] += vertex[i];
      vertex_set[vid[i]].push_back(i);
    }
  }
  void topo_sort() {
    vector<ll> rnum(size_scc,0);
    rep(i,size_scc) for (auto x: adj_scc[i]) rnum[x]++;
    queue<ll> top; rep(i,size_scc) if (rnum[i]==0) top.push(i);
    while (top.size()) {
      ll now = top.front(); top.pop();
      topo.push_back(now);
      for (auto x: adj_scc[now]) { 
        rnum[x]--; 
        if (rnum[x]==0) top.push(x); 
      }
    }
  }
  void calc() {
    vector<ll> order(size,-1), revorder(size), vid(size,-1);
    ll o = size-1, v = 0;
    rep(i,size) dfs_std(i,o,order);
    rep(i,size) revorder[order[i]] = i;
    rep(i,size) if (vid[revorder[i]]==-1) { dfs_rev(revorder[i],v,vid); v++; }
    restruct(v,vid);
    topo_sort();
  }
  void output() {
    cout << size_scc << endl;
    for (auto x: topo) {
      cout << vertex_set[x].size() << " ";
      debug(all(vertex_set[x]));
    }
  }
};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  ll N, D; cin >> N >> D;
  ll X[N], Y[N]; rep(i,N) cin >> X[i] >> Y[i];

  StrongConnectedComponent scc(N*2);
  rep(i,N) rep(j,N) {
    if (i==j) continue;
    if (abs(X[i]-X[j])<D) scc.add_edge(i,j+N);
    if (abs(X[i]-Y[j])<D) scc.add_edge(i,j);
    if (abs(Y[i]-X[j])<D) scc.add_edge(i+N,j+N);
    if (abs(Y[i]-Y[j])<D) scc.add_edge(i+N,j);
  }
  scc.calc();

  vector<ll> order = scc.topo; reverse(all(order));
  ll pos[2*N]; rep(i,order.size()) for (auto x: scc.vertex_set[order[i]]) pos[x] = i;
  bool ok = true; rep(i,N) ok &= pos[i]!=pos[i+N];
  if (ok) {
    cout << "Yes" << endl;
    rep(i,N) cout << (pos[i]<pos[i+N] ? X[i] : Y[i]) << endl;
  }
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 4144