#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

using CostType = ll;
struct Edge {
  int src, dst; CostType cost;
  Edge(int src, int dst, CostType cost = 0) : src(src), dst(dst), cost(cost) {}
  inline bool operator<(const Edge &x) const {
    return cost != x.cost ? cost < x.cost : dst != x.dst ? dst < x.dst : src < x.src;
  }
  inline bool operator<=(const Edge &x) const { return !(x < *this); }
  inline bool operator>(const Edge &x) const { return x < *this; }
  inline bool operator>=(const Edge &x) const { return !(*this < x); }
};

struct SCC {
  vector<int> id;
  vector<vector<int>> vertices;
  vector<vector<Edge>> comp;

  SCC(const vector<vector<Edge>> &graph, bool heavy = false) : graph(graph), heavy(heavy) {
    n = graph.size();
    rev_graph.resize(n);
    REP(i, n) for (const Edge &e : graph[i]) {
      rev_graph[e.dst].emplace_back(e.dst, e.src, e.cost);
    }
    used.assign(n, false);
    id.assign(n, -1);
    REP(i, n) {
      if (!used[i]) dfs(i);
    }
    int now = 0;
    for (int i = n - 1; i >= 0; --i) {
      if (id[order[i]] == -1) {
        if (heavy) vertices.emplace_back();
        rev_dfs(order[i], now++);
      }
    }
    comp.resize(now);
    REP(i, n) for (const Edge &e : graph[i]) {
      if (id[i] != id[e.dst]) comp[id[i]].emplace_back(id[i], id[e.dst], e.cost);
    }
    // if (heavy) {
    //   REP(i, now) sort(ALL(vertices[i]));
    // }
  }

private:
  bool heavy;
  int n;
  vector<vector<Edge>> graph, rev_graph;
  vector<bool> used;
  vector<int> order;

  void dfs(int ver) {
    used[ver] = true;
    for (const Edge &e : graph[ver]) {
      if (!used[e.dst]) dfs(e.dst);
    }
    order.emplace_back(ver);
  }

  void rev_dfs(int ver, int now) {
    id[ver] = now;
    if (heavy) vertices[now].emplace_back(ver);
    for (Edge &e : rev_graph[ver]) {
      if (id[e.dst] == -1) rev_dfs(e.dst, now);
    }
  }
};

struct TwoSat {
  TwoSat(int n) : n(n), graph(n << 1) {}

  int negate(int x) const { return (n + x) % (n << 1); }

  void add_or(int x, int y) {
    graph[negate(x)].emplace_back(negate(x), y);
    graph[negate(y)].emplace_back(negate(y), x);
  }

  void add_if(int x, int y) { add_or(negate(x), y); }

  void add_nand(int x, int y) { add_or(negate(x), negate(y)); }

  void set_true(int x) { add_or(x, x); }

  void set_false(int x) { set_true(negate(x)); }

  vector<bool> build() const {
    SCC scc(graph);
    vector<bool> res(n);
    REP(i, n) {
      if (scc.id[i] == scc.id[negate(i)]) return {};
      res[i] = scc.id[negate(i)] < scc.id[i];
    }
    return res;
  }

private:
  int n;
  vector<vector<Edge>> graph;
};

int main() {
  int n, d; cin >> n >> d;
  vector<int> x(n), y(n); REP(i, n) cin >> x[i] >> y[i];
  TwoSat ts(n);
  REP(i, n) FOR(j, i + 1, n) {
    if (abs(x[i] - x[j]) < d) ts.add_nand(i, j);
    if (abs(x[i] - y[j]) < d) ts.add_nand(i, ts.negate(j));
    if (abs(y[i] - x[j]) < d) ts.add_nand(ts.negate(i), j);
    if (abs(y[i] - y[j]) < d) ts.add_nand(ts.negate(i), ts.negate(j));
  }
  vector<bool> ans = ts.build();
  if (ans.empty()) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  REP(i, n) cout << (ans[i] ? x[i] : y[i]) << '\n';
  return 0;
}


Measured memory_bytes: 4136