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<iostream>
#include<algorithm>
using namespace std;
//Strongly Connected Components
#include<vector>
struct SCC{
	int n;
	vector<int>comp,order;
	vector<bool>used;
	vector<vector<int> >G,RG;
	SCC(int _n=0):n(_n),comp(_n,-1),used(_n,false),G(_n),RG(_n){}
	void add_edge(int from,int to)
	{
		G[from].push_back(to);
		RG[to].push_back(from);
	}
	void copy(const vector<vector<int> >&H)
	{
		for(int i=0;i<H.size();i++)
		{
			for(int j=0;j<H[i].size();j++)
			{
				G[i].push_back(H[i][j]);
				RG[H[i][j]].push_back(i);
			}
		}
	}
	int operator[](int u)const{return comp[u];}
	void dfs(int u)
	{
		used[u]=true;
		for(int i=0;i<G[u].size();i++)if(!used[G[u][i]])dfs(G[u][i]);
		order.push_back(u);
	}
	void rdfs(int u,int cnt)
	{
		comp[u]=cnt;
		for(int i=0;i<RG[u].size();i++)if(comp[RG[u][i]]==-1)rdfs(RG[u][i],cnt);
	}
	int build()
	{
		for(int i=0;i<n;i++)if(!used[i])dfs(i);
		int cnt=0;
		for(int i=n-1;i>=0;i--)if(comp[order[i]]==-1)rdfs(order[i],cnt++);
		return cnt;
	}
	int build(vector<vector<int> >&H)
	{
		int ret=build();
		H.assign(ret,vector<int>());
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<G[i].size();j++)
			{
				if(comp[i]!=comp[G[i][j]])
					H[comp[i]].push_back(comp[G[i][j]]);
			}
		}
		return ret;
	}
};
int N,D;
int X[1000],Y[1000];
int main()
{
	cin>>N>>D;
	SCC P(2*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)
		{
			P.add_edge(2*i,2*j+1);
			P.add_edge(2*j,2*i+1);
		}
		if(abs(Y[i]-X[j])<D)
		{
			P.add_edge(2*i+1,2*j+1);
			P.add_edge(2*j,2*i);
		}
		if(abs(X[i]-Y[j])<D)
		{
			P.add_edge(2*i,2*j);
			P.add_edge(2*j+1,2*i+1);
		}
		if(abs(Y[i]-Y[j])<D)
		{
			P.add_edge(2*i+1,2*j);
			P.add_edge(2*j+1,2*i);
		}
	}
	P.build();
	bool ok=true;
	for(int i=0;i<N;i++)if(P[2*i]==P[2*i+1])ok=false;
	if(ok)
	{
		cout<<"Yes"<<endl;
		for(int i=0;i<N;i++)
		{
			cout<<(P[2*i]>P[2*i+1]?X[i]:Y[i])<<endl;
		}
	}
	else
	{
		cout<<"No"<<endl;
	}
}