#include <bits/stdc++.h>
using namespace std;

void dfs(int v, vector<vector<int>> &adj, vector<bool> &visited, stack<int> &s) {
	visited[v] = true;
	//cout << v << endl;
	for(auto x : adj[v]) {
		if(!visited[x]) dfs(x, adj, visited, s);
	}
	s.push(v);
}

void dfs1(int v, vector<vector<int>> &adj, vector<int> &comp, int t) {
	comp[v] = t;
	for(auto x : adj[v]) {
		if(comp[x] == -1) dfs1(x, adj, comp, t);
	}
}

int main() {
	int n, d;
	cin >> n >> d;
	vector<pair<int, int>> pt(n);
	for(int i = 0; i < n; i++) cin >> pt[i].first >> pt[i].second;
	vector<vector<int>> adj(2*n), adjt(2*n);
	for(int i = 0; i < n; i++) {
		//adj[2*i].first = pt[i].first;
		//adj[2*i+1].first = pt[i].second;
		for(int j = 0; j < n; j++) {
			if(i != j) {
				if(abs(pt[i].first - pt[j].first) < d) { // cannot take both simultaneously
					adj[2*i].push_back(2*j+1);
					adjt[2*j+1].push_back(2*i);
				}
				if(abs(pt[i].first - pt[j].second) < d) { // cannot take both simultaneously
					adj[2*i].push_back(2*j);
					adjt[2*j].push_back(2*i);
				}
				if(abs(pt[i].second - pt[j].first) < d) { // cannot take both simultaneously
					adj[2*i+1].push_back(2*j+1);
					adjt[2*j+1].push_back(2*i+1);
				}
				if(abs(pt[i].second - pt[j].second) < d) { // cannot take both simultaneously
					adj[2*i+1].push_back(2*j);
					adjt[2*j].push_back(2*i+1);
				}
			}
		}
	}
	stack<int> s;
	vector<bool> visited(2*n, false);
	vector<int> comp(2*n, -1); 
	for(int i = 0; i < 2*n; i++) {
		if(!visited[i]) dfs(i, adj, visited, s);
	}
	//visited.assign(2*n, false);
	int j = 0;
	while(!s.empty()) {
		int i = s.top();
		s.pop();
		if(comp[i] == -1) dfs1(i, adjt, comp, j++);
	}
	vector<int> ans(n);
	bool ispos = true;
	for(int i = 0; i < n; i++) {
		if(comp[2*i] == comp[2*i+1]) {
			ispos = false;
			break;
		}
		ans[i] = comp[2*i] < comp[2*i+1] ? pt[i].second : pt[i].first;
	}
	if(!ispos) cout << "No";
	else {
		cout << "Yes" << endl;
		for(auto x : ans) cout << x << endl;
	}
	return 0;
}
