Problem: Consider placing N flags on a line. Flags are numbered through 1 to N.

Flag i can be placed on the coordinate X_i or Y_i. For any two different flags, the distance between them should be at least D.

Decide whether it is possible to place all N flags. If it is possible, print such a configulation.

Constraints

* 1 \leq N \leq 1000
* 0 \leq D \leq 10^9
* 0 \leq X_i < Y_i \leq 10^9
* All values in Input are integer.

Input

Input is given from Standard Input in the following format:


N D
X_1 Y_1
X_2 Y_2
\vdots
X_N Y_N


Output

Print `No` if it is impossible to place N flags.

If it is possible, print `Yes` first. After that, print N lines. i-th line of them should contain the coodinate of flag i.

Examples

Input

3 2
1 4
2 5
0 6


Output

Yes
4
2
0


Input

3 3
1 4
2 5
0 6


Output

No

Solution (in CPP):

Solution:
#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;
}