using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoderLibraryCSharp.Examples
{
    public static class Program
    {
        public static void Main()
        {
            var ND = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
            var (N, D) = (ND[0], ND[1]);
            var X = new int[N];
            var Y = new int[N];
            for (var i = 0; i < N; i++)
            {
                var XY = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
                (X[i], Y[i]) = (XY[0], XY[1]);
            }

            var ts = new TwoSatisfiability(N);
            for (var i = 0; i < N; i++)
            {
                for (var j = i + 1; j < N; j++)
                {
                    if (System.Math.Abs(X[i] - X[j]) < D) ts.AddClause(i, false, j, false);
                    if (System.Math.Abs(X[i] - Y[j]) < D) ts.AddClause(i, false, j, true);
                    if (System.Math.Abs(Y[i] - X[j]) < D) ts.AddClause(i, true, j, false);
                    if (System.Math.Abs(Y[i] - Y[j]) < D) ts.AddClause(i, true, j, true);
                }
            }

            if (!ts.IsSatisfiable())
            {
                Console.WriteLine("No");
                return;
            }

            Console.WriteLine("Yes");
            var answer = ts.Answer;
            for (var i = 0; i < N; i++)
                Console.WriteLine(answer[i] ? X[i] : Y[i]);
        }
    }
}

namespace AtCoderLibraryCSharp
{
    public class TwoSatisfiability
    {
        public bool[] Answer { get; }

        private readonly int _n;
        private readonly StronglyConnectedComponent _scc;

        public TwoSatisfiability(int n = 0)
        {
            _n = n;
            Answer = new bool[n];
            _scc = new StronglyConnectedComponent(2 * n);
        }

        public void AddClause(int i, bool f, int j, bool g)
        {
            if (i < 0 || _n < i) throw new IndexOutOfRangeException(nameof(i));
            if (j < 0 || _n < j) throw new IndexOutOfRangeException(nameof(j));
            _scc.AddEdge(2 * i + (f ? 0 : 1), 2 * j + (g ? 1 : 0));
            _scc.AddEdge(2 * j + (g ? 0 : 1), 2 * i + (f ? 1 : 0));
        }

        public bool IsSatisfiable()
        {
            var (_, tmp) = _scc.Ids();
            var ids = tmp.ToArray();
            for (var i = 0; i < _n; i++)
            {
                if (ids[2 * i] == ids[2 * i + 1]) return false;
                Answer[i] = ids[2 * i] < ids[2 * i + 1];
            }

            return true;
        }
    }
}

namespace AtCoderLibraryCSharp
{
    public class StronglyConnectedComponent
    {
        private readonly struct Edge
        {
            public readonly int To;
            public Edge(int to) => To = to;
        }

        private readonly int _n;
        private readonly List<(int, Edge)> _edges;

        public StronglyConnectedComponent(int n = 0)
        {
            _n = n;
            _edges = new List<(int, Edge)>();
        }

        public void AddEdge(int from, int to)
        {
            if (from < 0 || _n <= from) throw new IndexOutOfRangeException(nameof(from));
            if (to < 0 || _n <= to) throw new IndexOutOfRangeException(nameof(to));
            _edges.Add((from, new Edge(to)));
        }

        public (int, IEnumerable<int>) Ids()
        {
            var g = new CompressedSparseRow<Edge>(_n, _edges);
            var (nowOrd, groupNum) = (0, 0);
            var visited = new Stack<int>(_n);
            var low = new int[_n];
            var ord = Enumerable.Repeat(-1, _n).ToArray();
            var ids = new int[_n];

            void Dfs(int v)
            {
                low[v] = ord[v] = nowOrd++;
                visited.Push(v);
                for (var i = g.Start[v]; i < g.Start[v + 1]; i++)
                {
                    var to = g.Edges[i].To;
                    if (ord[to] == -1)
                    {
                        Dfs(to);
                        low[v] = System.Math.Min(low[v], low[to]);
                    }
                    else low[v] = System.Math.Min(low[v], ord[to]);
                }

                if (low[v] != ord[v]) return;
                while (true)
                {
                    var u = visited.Pop();
                    ord[u] = _n;
                    ids[u] = groupNum;
                    if (u == v) break;
                }

                groupNum++;
            }

            for (var i = 0; i < _n; i++)
                if (ord[i] == -1)
                    Dfs(i);

            for (var i = 0; i < _n; i++) ids[i] = groupNum - 1 - ids[i];

            return (groupNum, ids);
        }

        public IEnumerable<IEnumerable<int>> GetGraph()
        {
            var (groupNum, tmp) = Ids();
            var ids = tmp.ToArray();
            var groups = new List<int>[groupNum].Select(x => new List<int>()).ToArray();
            foreach (var (id, i) in ids.Select((x, i) => (x, i))) groups[id].Add(i);
            return groups;
        }
    }
}

namespace AtCoderLibraryCSharp
{
    public class CompressedSparseRow<T>
    {
        public int[] Start { get; }
        public T[] Edges { get; }

        public CompressedSparseRow(int n, IEnumerable<(int, T)> edges)
        {
            Start = new int[n + 1];
            var es = edges.ToArray();
            Edges = new T[es.Length];
            foreach (var e in es) Start[e.Item1 + 1]++;
            for (var i = 0; i < n; i++) Start[i + 1] += Start[i];
            var counter = Start.ToArray();
            foreach (var (i, t) in es) Edges[counter[i]++] = t;
        }
    }
}

Measured memory_bytes: 28924