#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, d) = (v[0] as usize, v[1]);
    let mut cands = vec![];
    for i in 0..n {
        let v = read_vec::<i64>();
        let (x, y) = (v[0], v[1]);
        cands.push((x, y));
    }
    // [0, n): x (not y)
    // [n, 2 * n): y (not x)
    let mut g = vec![vec![]; 2 * n];
    let mut rg = vec![vec![]; 2 * n];
    for i in 0..n {
        let (xi, yi) = cands[i];
        for j in i + 1..n {
            let (xj, yj) = cands[j];

            if (xi - xj).abs() < d {
                add_edge(2 * i, 2 * j + 1, &mut g, &mut rg);
                add_edge(2 * j, 2 * i + 1, &mut g, &mut rg);
            }
            if (xi - yj).abs() < d {
                add_edge(2 * i, 2 * j, &mut g, &mut rg);
                add_edge(2 * j + 1, 2 * i + 1, &mut g, &mut rg);
            }
            if (yi - xj).abs() < d {
                add_edge(2 * i + 1, 2 * j + 1, &mut g, &mut rg);
                add_edge(2 * j, 2 * i, &mut g, &mut rg);
            }
            if (yi - yj).abs() < d {
                add_edge(2 * i + 1, 2 * j, &mut g, &mut rg);
                add_edge(2 * j + 1, 2 * i, &mut g, &mut rg);
            }
        }
    }
    let cmp = scc(&g, &rg);
    if (0..n).any(|i| cmp[2 * i] == cmp[2 * i + 1]) {
        println!("No");
        return;
    }
    println!("Yes");
    for i in 0..n {
        if cmp[2 * i] < cmp[2 * i + 1] {
            println!("{}", cands[i].1);
        } else {
            println!("{}", cands[i].0);
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

type Graph = Vec<Vec<usize>>;

fn dfs(v: usize, used: &mut Vec<bool>, g: &Graph, vs: &mut Vec<usize>) {
    used[v] = true;
    for &to in g[v].iter() {
        if !used[to] {
            dfs(to, used, g, vs);
        }
    }
    vs.push(v);
}

fn rdfs(v: usize, k: usize, used: &mut Vec<bool>, rg: &Graph, cmp: &mut Vec<usize>) {
    used[v] = true;
    cmp[v] = k;
    for &to in rg[v].iter() {
        if !used[to] {
            rdfs(to, k, used, rg, cmp);
        }
    }
}

fn add_edge(from: usize, to: usize, g: &mut Graph, rg: &mut Graph) {
    g[from].push(to);
    rg[to].push(from);
}

fn scc(g: &Graph, rg: &Graph) -> Vec<usize> {
    let mut used = vec![false; g.len()];
    let mut vs = vec![];
    for v in 0..g.len() {
        if !used[v] {
            dfs(v, &mut used, &g, &mut vs);
        }
    }
    let mut used = vec![false; g.len()];
    let mut cmp = vec![0usize; g.len()];
    let mut k = 0;
    for &i in vs.iter().rev() {
        if !used[i] {
            rdfs(i, k, &mut used, &rg, &mut cmp);
            k += 1;
        }
    }
    cmp
}


Measured memory_bytes: 2364