#include <vector>

struct strongly_connected_componects {
  int n;
  std::vector<std::vector<int>> G;
  std::vector<int> id;
  std::vector<int> low;
  std::vector<int> num;
  std::vector<int> st;
  std::vector<bool> in_st;
  int cnt;
  int group;

  strongly_connected_componects(int n):
    n(n), G(n) {}

  void add_edge(int a, int b) {
    G[a].emplace_back(b);
  }

  void visit(int v) {
    low[v] = num[v] = ++cnt;
    st.emplace_back(v);
    in_st[v] = true;

    for(auto t: G[v]) {
      if(num[t] == 0) {
        visit(t);
        low[v] = std::min(low[v], low[t]);
      }
      else if(in_st[t]) {
        low[v] = std::min(low[v], num[t]);
      }
    }

    if(low[v] == num[v]) {
      while(true) {
        int t = st.back();
        st.pop_back();
        in_st[t] = false;
        id[t] = group;
        if(v == t) break;
      }
      group++;
    }
  }

  // id... トポロジカル順
  void build_scc() {
    id.assign(n, -1);
    low.assign(n, 0);
    num.assign(n, 0);
    st.reserve(n);
    in_st.assign(n, false);
    cnt = 0;
    group = 0;
    for(int i = 0;i < n;i++) {
      if(num[i] == 0) {
        visit(i);
      }
    }
    for(int i = 0; i < n; i++) {
      id[i] = group - 1 - id[i];
    }
  }
};

#include <tuple>

struct two_sat {
  int n;
  strongly_connected_componects scc;
  two_sat(int n): n(n), scc(n * 2) {}

  // add ((x == x_is) or (y == y_is))
  void add_closure(int x, bool x_is, int y, bool y_is) {
    scc.add_edge(x + n * (x_is ? 0 : 1), y + n * (y_is ? 1 : 0));
    scc.add_edge(y + n * (y_is ? 0 : 1), x + n * (x_is ? 1 : 0));
  }

  std::tuple<bool, std::vector<bool>> build_ans() {
    scc.build_scc();
    std::vector<bool> ans(n);
    for(int i = 0;i < n;i++) {
      if(scc.id[i] == scc.id[i + n]) { return { false, std::vector<bool>() }; }
      ans[i] = scc.id[i] < scc.id[i + n];
    }
    return { true, std::move(ans) };
  }
};


#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
  return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << "[";
  for(int i = 0;i < v.size();i++) os << v[i] << ", ";
  return (os << "]");
}

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }


int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int N, D;
  cin >> N >> D;
  vector<int> X(N);
  vector<int> Y(N);
  rep(i,0,N) {
    cin >> X[i] >> Y[i];
  }
  two_sat sat(N);
  rep(i,0,N) {
    rep(j,i + 1,N) {
      if(abs(X[i] - X[j]) < D) {
        sat.add_closure(i, false, j, false);
      }
      if(abs(X[i] - Y[j]) < D) {
        sat.add_closure(i, false, j, true);
      }
      if(abs(Y[i] - X[j]) < D) {
        sat.add_closure(i, true, j, false);
      }
      if(abs(Y[i] - Y[j]) < D) {
        sat.add_closure(i, true, j, true);
      }
    }
  }
  auto [sati, ans] = sat.build_ans();
  if(sati) {
    cout << "Yes\n";
    for(int i = 0; i < N;i++) {
      if(ans[i]) {
        cout << X[i] << '\n';
      }
      else {
        cout << Y[i] << '\n';
      }
    }
  }
  else {
    cout << "No\n";
  }
}


Measured memory_bytes: 3752