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

#[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 n = read::<usize>();
    let mut edges: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let v = read_vec::<usize>();
        let (a, b) = (v[0] - 1, v[1] - 1);
        edges[a].push(b);
        edges[b].push(a);
    }
    let k = read::<usize>();
    let mut limits = vec![(-std::i64::MAX, std::i64::MAX); n];
    let mut mod2 = vec![2; n]; // if 2, undefined.
    for _ in 0..k {
        let v = read_vec::<usize>();
        let (v, p) = (v[0] - 1, v[1] as i64);
        limits[v] = (p, p);
        mod2[v] = p % 2;
    }

    let mut tree: Vec<Vec<usize>> = vec![Vec::new(); n];
    let mut parent_dict: HashMap<usize, usize> = HashMap::new();
    make_tree(0, n, &edges, &mut tree, &mut parent_dict);
    let mut topological_sorted_indexes = vec![0];
    topological_dfs(0, &tree, &mut topological_sorted_indexes);

    for &ti in topological_sorted_indexes.iter() {
        for &ci in tree[ti].iter() {
            if mod2[ti] == 2 {
                if mod2[ci] != 2 {
                    mod2[ti] = 1 - mod2[ci];
                }
            } else {
                if mod2[ti] == mod2[ci] {
                    println!("No");
                    return;
                }
            }
            if limits[ci] != (-std::i64::MAX, std::i64::MAX) {
                limits[ti].0 = max(limits[ti].0, limits[ci].0 - 1);
                limits[ti].1 = min(limits[ti].1, limits[ci].1 + 1);
            }
        }
    }
    for &limit in limits.iter() {
        if limit.0 > limit.1 {
            println!("No");
            return;
        }
    }

    let mut answers = vec![0; n];
    for &ti in topological_sorted_indexes.iter() {
        answers[ti] = limits[ti].0;
        for &ci in tree[ti].iter() {
            limits[ci].0 = max(limits[ci].0, answers[ti] - 1);
            limits[ci].1 = min(limits[ci].1, answers[ti] + 1);
        }
    }
    unreachable!();
    println!("Yes");
    for ans in answers {
        println!("{}", ans);
    }
}

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()
}

fn make_tree(
    cur_idx: usize,
    parent_idx: usize,
    edges: &Vec<Vec<usize>>,
    tree: &mut Vec<Vec<usize>>,
    parent_dict: &mut HashMap<usize, usize>,
) {
    for child_idx in edges[cur_idx].iter() {
        if *child_idx == parent_idx {
            continue;
        }
        tree[cur_idx].push(*child_idx);
        parent_dict.insert(*child_idx, cur_idx);
        make_tree(*child_idx, cur_idx, edges, tree, parent_dict);
    }
}

fn topological_dfs(cur_idx: usize, tree: &Vec<Vec<usize>>, result: &mut Vec<usize>) {
    for child_idx in tree[cur_idx].iter() {
        result.push(*child_idx);
        topological_dfs(*child_idx, tree, result);
    }
}
