import os
import sys

import numpy as np


def solve(inp):
    SCC_LINKS = []

    def scc_init(n):
        int_list = [0]
        int_list.clear()
        links = [int_list.copy() for _ in range(n)]
        rev_links = [int_list.copy() for _ in range(n)]
        SCC_LINKS.append((links, rev_links))
        return len(SCC_LINKS) - 1

    def scc_add_link(ins, frm, to):
        links, rev_links = SCC_LINKS[ins]
        links[frm].append(to)
        rev_links[to].append(frm)

    def scc_exe(ins):
        links, rev_links = SCC_LINKS[ins]
        n = len(links)
        stack = np.zeros(n * 2, np.int64)
        checked = np.zeros(n, np.int8)
        postorder = np.zeros(n, np.int64)
        pi = 0

        for v in range(n):
            if checked[v]:
                continue

            # DFS1
            stack[0] = 0
            stack[1] = v
            si = 2
            while si > 0:
                i = stack[si - 2]
                v = stack[si - 1]
                if i == 0 and checked[v]:
                    si -= 2
                    continue
                checked[v] = 1
                l = len(links[v])
                while i < l and checked[links[v][i]] == 1:
                    i += 1
                if i == l:
                    postorder[pi] = v
                    pi += 1
                    si -= 2
                    continue
                stack[si - 2] = i + 1
                stack[si] = 0
                stack[si + 1] = links[v][i]
                si += 2

        postorder = postorder[::-1]
        checked = np.zeros(n, np.int8)
        sccs = []

        for v in postorder:
            if checked[v]:
                continue

            # DFS2
            stack[0] = v
            si = 1
            checked[v] = 1
            scc = [v]
            while si > 0:
                si -= 1
                v = stack[si]
                for u in rev_links[v]:
                    if checked[u] == 0:
                        checked[u] = 1
                        stack[si] = u
                        si += 1
                        scc.append(u)
            sccs.append(scc)

        return sccs

    def twosat_init(n):
        return scc_init(n * 2)

    def twosat_add_clause(ins, i, f, j, g):
        """ Add constraint that (Ai = f:0/1) && (Aj = g:0/1) is banned. """
        i <<= 1
        j <<= 1
        scc_add_link(ins, i + f, j + (g ^ 1))
        scc_add_link(ins, j + g, i + (f ^ 1))

    def twosat_satisfy(ins):
        """
        :return: if can satisfy [0,1,0,...], else None
        """
        n = len(SCC_LINKS[ins][0]) >> 1
        group_ids = np.full(n, -1, np.int64)
        result = np.full(n, -1, np.int8)

        sccs = scc_exe(ins)

        # Settle greedily from downstream in the topological order of scc.
        sccs.reverse()
        for g, scc in enumerate(sccs):
            for v in scc:
                i = v >> 1
                if result[i] == -1:
                    result[i] = v & 1
                    group_ids[i] = g
                elif group_ids[i] == g:
                    return None
        return result

    n = inp[0]
    d = inp[1]
    xxx = inp[2::2]
    yyy = inp[3::2]

    ins = twosat_init(n)

    for i in range(n):
        for j in range(i + 1, n):
            if abs(xxx[i] - xxx[j]) < d:
                twosat_add_clause(ins, i, 0, j, 0)
            if abs(xxx[i] - yyy[j]) < d:
                twosat_add_clause(ins, i, 0, j, 1)
            if abs(yyy[i] - xxx[j]) < d:
                twosat_add_clause(ins, i, 1, j, 0)
            if abs(yyy[i] - yyy[j]) < d:
                twosat_add_clause(ins, i, 1, j, 1)

    result = twosat_satisfy(ins)
    if result is None:
        return None

    ans = np.zeros(n, np.int64)
    for i in range(n):
        ans[i] = yyy[i] if result[i] else xxx[i]

    return ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
if ans is None:
    print('No')
else:
    print('Yes')
    print('\n'.join(map(str, ans)))


Measured memory_bytes: 27932