using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		int n=s[0];
		var h=new int[n][];
		var sat=new Tsat(n);
		for(int i = 0;i<n;i++) {
			h[i]=sc.Ia;
			for(int j = i-1;j>=0;j--) {
				if(Abs(h[i][0]-h[j][0])<s[1]){
					sat.Edge(i,0,j,1);
					sat.Edge(j,0,i,1);
				}
				if(Abs(h[i][0]-h[j][1])<s[1]){
					sat.Edge(i,0,j,0);
					sat.Edge(j,1,i,1);
				}
				if(Abs(h[i][1]-h[j][0])<s[1]){
					sat.Edge(i,1,j,1);
					sat.Edge(j,0,i,0);
				}
				if(Abs(h[i][1]-h[j][1])<s[1]){
					sat.Edge(i,1,j,0);
					sat.Edge(j,1,i,0);
				}
			}
		}
		sat.Scc();
		StringBuilder sb=new StringBuilder();
		for(int i = 0;i<n;i++) {
			var e=sat.Ck(i);
			if(e==-1){
				Console.WriteLine("No");
				return;
			}
			else{sb.Append(h[i][e]+"\n");}
		}
		Console.WriteLine("Yes");
		Console.Write(sb);
	}
}
public class Tsat{
	public List<int>[] li,lir,lid;
	public int[] zt;
	private int n;
	public Tsat(int n){
		this.n=n<<1;
		li=new List<int>[this.n];
		lir=new List<int>[this.n];
		for(int i=0;i<this.n;i++){
			li[i]=new List<int>();
			lir[i]=new List<int>();
		}
	}
	public void Edge(int a,int b){
		li[a].Add(b);
		lir[b].Add(a);
	}
	public void Edge(int a,int c,int b,int d){
		a=(a<<1)+c;b=(b<<1)+d;
		li[a].Add(b);
		lir[b].Add(a);
	}
	public int Ck(int a){
		a<<=1;
		return zt[a]==zt[a+1]?-1:(zt[a]>zt[a+1]?0:1);
	}
	public void Scc(){
		var h=new int[n];
		var b=new bool[n];
		zt=new int[n];
		int kk=n-1,km=0;
		for(int i=0;i<n;i++){if(!b[i]){Fud1(i);}}
		for(int i=0;i<n;i++){
			if(b[h[i]]){
				Fud2(h[i]);
				km++;
			}
		}
		lid=new List<int>[km];
		for(int i=0;i<km;i++){lid[i]=new List<int>();}
		for(int i=0;i<n;i++){
			for(int j=0;j<li[i].Count;j++){if(zt[i]!=zt[li[i][j]]){lid[zt[i]].Add(zt[li[i][j]]);}}
		}
		for(int i=0;i<km;i++){lid[i]=lid[i].Distinct().ToList();}
		void Fud1(int a){
			b[a]=true;
			for(int i=0;i<li[a].Count;i++){if(!b[li[a][i]]){Fud1(li[a][i]);}}
			h[kk--]=a;
		}
		void Fud2(int a){
			zt[a]=km;
			b[a]=false;
			for(int i=0;i<lir[a].Count;i++){if(b[lir[a][i]]){Fud2(lir[a][i]);}}
		}
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 29784