#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;

struct StronglyConnectedComponents {
	int n, group_num, now_ord;
	vector<vector<int>> g;
	vector<int> low, ord, idx;
	StronglyConnectedComponents(int _n) :n(_n), low(n), ord(n, -1), idx(n), g(n), group_num(0), now_ord(0) {}
	void add_edge(int from, int to) {
		g[from].emplace_back(to);
	}
	void dfs(int cur, vector<int>& visited) {
		ord[cur] = low[cur] = now_ord++;
		visited.emplace_back(cur);
		for (auto nxt : g[cur]) {
			if (ord[nxt] == -1) {
				dfs(nxt, visited);
				chmin(low[cur], low[nxt]);
			}
			else {
				chmin(low[cur], ord[nxt]);
			}
		}
		if (ord[cur] == low[cur]) {
			while (true) {
				int v = visited.back();
				visited.pop_back();
				ord[v] = n; //別のdfs木からこないように
				idx[v] = group_num;
				if (cur == v) break;
			}
			group_num++;
		}
	}



	//sccのidxに入ってる頂点番号 idxはトポロジカル順
	void build() {
		vector<int> visited;
		for (int i = 0; i < n; i++) if (ord[i] == -1) dfs(i, visited);
		for (int i = 0; i < n; i++) idx[i] = group_num - 1 - idx[i];
	}
	//build()の後にやる
	vector<vector<int>> groups() {
		vector<vector<int>> ret(group_num);
		for (int i = 0; i < n; i++) {
			ret[idx[i]].emplace_back(i);
		}
		return ret;
	}
	int operator[](int i) { return idx[i]; }
};


struct TwoSAT {
public:
	int n;
	vector<bool> res;
	StronglyConnectedComponents scc;
	TwoSAT(int _n) :n(_n), res(n), scc(2 * n) {}

	void add_clause(int i, bool f, int j, bool g) {
		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() {
		scc.build();
		for (int i = 0; i < n; i++) {
			if (scc[i * 2 + 0] == scc[i * 2 + 1]) return false;
			res[i] = scc[i * 2 + 0] < scc[i * 2 + 1];
		}
		return true;
	}
	bool operator[](int i) { return res[i]; }
};

template<typename T>
struct Compress {
	vector<T> v;
	Compress() {}
	Compress(vector<T> _v) :v(_v) {
		sort(v.begin(), v.end());
		v.erase(unique(v.begin(), v.end()), v.end());
	}

	void build(vector<T> _v) {
		v = _v;
		sort(v.begin(), v.end());
		v.erase(unique(v.begin(), v.end()), v.end());
	}
	int get(T x) {
		return lower_bound(v.begin(), v.end(), x) - v.begin();
	}

	T& operator[](int i) { return v[i]; }


	int size() {
		return (int)v.size();
	}
};

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, D; cin >> n >> D;
	TwoSAT ts(n);
	vector<int> x(n), y(n);
	for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (abs(x[i] - x[j]) < D) ts.add_clause(i, false, j, false);
			if (abs(x[i] - y[j]) < D) ts.add_clause(i, false, j, true);
			if (abs(y[i] - x[j]) < D) ts.add_clause(i, true, j, false);
			if (abs(y[i] - y[j]) < D) ts.add_clause(i, true, j, true);
		}
	}
	if (!ts.satisfiable()) cout << "No" << "\n";
	else {
		cout << "Yes" << "\n";
		for (int i = 0; i < n; i++) {
			if (ts[i]) cout << x[i] << "\n";
			else cout << y[i] << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3740