package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	d := getNextInt(scanner)
	xx := make([]int, n)
	yy := make([]int, n)
	for i := 0; i < n; i++ {
		xx[i] = getNextInt(scanner)
		yy[i] = getNextInt(scanner)
	}
	t := NewTwoSat(n)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			if abs(xx[i]-xx[j]) < d {
				t.AddClause(i, false, j, false)
			}
			if abs(xx[i]-yy[j]) < d {
				t.AddClause(i, false, j, true)
			}
			if abs(yy[i]-xx[j]) < d {
				t.AddClause(i, true, j, false)
			}
			if abs(yy[i]-yy[j]) < d {
				t.AddClause(i, true, j, true)
			}
		}
	}
	if t.Satisfiable() {
		fmt.Fprintln(writer, "Yes")
		answer := t.Answer()
		for i := 0; i < n; i++ {
			if answer[i] {
				fmt.Fprintln(writer, xx[i])
				continue
			}
			fmt.Fprintln(writer, yy[i])
		}
		return
	}
	fmt.Fprintln(writer, "No")
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

// TwoSat solves 2-SAT.
type TwoSat struct {
	n      int
	answer []bool
	scc    *SccGraph
}

// NewTwoSat creates a 2-SAT of n variables and 0 clauses.
func NewTwoSat(n int) *TwoSat {
	return &TwoSat{
		n:      n,
		answer: make([]bool, n),
		scc:    NewSccGraph(n << 1),
	}
}

// AddClause adds a clause (x_i = f) v (x_j = g)
func (t *TwoSat) AddClause(i int, f bool, j int, g bool) {
	i <<= 1
	j <<= 1
	switch {
	case f && g:
		t.scc.AddEdge(i, j+1)
		t.scc.AddEdge(j, i+1)
	case f && !g:
		t.scc.AddEdge(i, j)
		t.scc.AddEdge(j+1, i+1)
	case !f && g:
		t.scc.AddEdge(i+1, j+1)
		t.scc.AddEdge(j, i)
	default:
		t.scc.AddEdge(i+1, j)
		t.scc.AddEdge(j+1, i)
	}
}

// Satisfiable returns whether there is a truth assignment that satisfies all clauses.
func (t *TwoSat) Satisfiable() bool {
	_, id := t.scc.SccIds()
	for i := 0; i < t.n; i++ {
		ii := i << 1
		if id[ii] == id[ii+1] {
			return false
		}
		t.answer[i] = id[ii] < id[ii+1]
	}
	return true
}

// Answer returns a truth assignment that satisfies all clauses of the last call of satisfiable.
// If we call it before calling satisfiable or when the last call of satisfiable returns false, it returns the vector of length n with undefined elements.
func (t *TwoSat) Answer() []bool {
	return t.answer
}

// Csr edge list
type Csr struct {
	Start []int
	Elist []*Edge
}

// Pair holds starting point and Edge
type Pair struct {
	From int
	E    *Edge
}

// Edge holds end point
type Edge struct {
	To int
}

// SccGraph calculates the strongly connected components of directed graphs.
type SccGraph struct {
	n     int
	edges []*Pair
}

// NewCsr creates edge lists
func NewCsr(n int, edges []*Pair) *Csr {
	start := make([]int, n+1)
	counter := make([]int, n+1)
	elist := make([]*Edge, len(edges))
	for _, e := range edges {
		start[e.From+1]++
	}
	for i := 0; i < n; i++ {
		start[i+1] += start[i]
	}
	copy(counter, start)
	for _, e := range edges {
		elist[counter[e.From]] = e.E
		counter[e.From]++
	}

	return &Csr{Start: start, Elist: elist}
}

// NewSccGraph creates a directed graph with nn vertices and 0 edges.
func NewSccGraph(n int) *SccGraph {
	return &SccGraph{n: n, edges: make([]*Pair, 0)}
}

// AddEdge adds a directed edge from the vertex from to the vertex to.
func (s *SccGraph) AddEdge(from, to int) {
	s.edges = append(s.edges, &Pair{From: from, E: &Edge{To: to}})
}

// SccIds returns pair of (# of scc, scc id)
func (s *SccGraph) SccIds() (int, []int) {
	g := NewCsr(s.n, s.edges)
	var now, group int
	n := s.n
	visited := make([]int, 0)
	low := make([]int, n)
	ord := make([]int, n)
	ids := make([]int, n)
	for i := 0; i < n; i++ {
		ord[i] = -1
	}
	var dfs func(int)
	dfs = func(v int) {
		low[v] = now
		ord[v] = now
		now++
		visited = append(visited, v)
		for i := g.Start[v]; i < g.Start[v+1]; i++ {
			to := g.Elist[i].To
			if ord[to] == -1 {
				dfs(to)
				if low[v] > low[to] {
					low[v] = low[to]
				}
				continue
			}
			if low[v] > ord[to] {
				low[v] = ord[to]
			}
		}
		if low[v] == ord[v] {
			for i := len(visited) - 1; i >= 0; i-- {
				u := visited[i]
				ord[u] = n
				ids[u] = group
				visited = visited[:i]
				if v == u {
					break
				}
			}
			group++
		}
	}
	for i := 0; i < n; i++ {
		if ord[i] == -1 {
			dfs(i)
		}
	}
	for i := 0; i < n; i++ {
		ids[i] = group - 1 - ids[i]
	}
	return group, ids
}

// Scc returns the list of the "list of the vertices" that satisfies the following.
// Each vertex is in exactly one "list of the vertices".
// Each "list of the vertices" corresponds to the vertex set of a strongly connected component.
// The order of the vertices in the list is undefined.
// The list of "list of the vertices" are sorted in topological order, i.e., for two vertices u, v in different strongly connected components, if there is a directed path from u to v, the list contains u appears earlier than the list contains v.
func (s *SccGraph) Scc() [][]int {
	group, ids := s.SccIds()
	groups := make([][]int, group)
	for i := 0; i < s.n; i++ {
		groups[ids[i]] = append(groups[ids[i]], i)
	}
	return groups
}


Measured memory_bytes: 2196