Problem:
Score : 600 points

Problem Statement

We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.
For each k=1, ..., N, solve the problem below:

Consider writing a number on each vertex in the tree in the following manner:

First, write 1 on Vertex k.

Then, for each of the numbers 2, ..., N in this order, write the number on the vertex chosen as follows:

Choose a vertex that still does not have a number written on it and is adjacent to a vertex with a number already written on it. If there are multiple such vertices, choose one of them at random.

Find the number of ways in which we can write the numbers on the vertices, modulo (10^9+7).

Constraints

2 \leq N \leq 2 \times 10^5

1 \leq a_i,b_i \leq N

The given graph is a tree.

Input

Input is given from Standard Input in the following format:

N
a_1 b_1
:
a_{N-1} b_{N-1}

Output

For each k=1, 2, ..., N in this order, print a line containing the answer to the problem.

Sample Input 1

3
1 2
1 3

Sample Output 1

2
1
1

The graph in this input is as follows:

For k=1, there are two ways in which we can write the numbers on the vertices, as follows:

Writing 1, 2, 3 on Vertex 1, 2, 3, respectively

Writing 1, 3, 2 on Vertex 1, 2, 3, respectively

Sample Input 2

2
1 2

Sample Output 2

1
1

The graph in this input is as follows:

Sample Input 3

5
1 2
2 3
3 4
3 5

Sample Output 3

2
8
12
3
3

The graph in this input is as follows:

Sample Input 4

8
1 2
2 3
3 4
3 5
3 6
6 7
6 8

Sample Output 4

40
280
840
120
120
504
72
72

The graph in this input is as follows:

Solution in Rust (1.15.1) (judge verdict: Accepted)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
use proconio::input;
use proconio::marker::*;

#[modtype::use_modtype]
type F = modtype::F<1_000_000_007u64>;

fn gen_factorial(n: usize) -> (Vec<F>, Vec<F>) {
    let mut p = vec![F(1); n + 1];
    let mut r = vec![F(1); n + 1];

    for i in 0..n {
        p[i + 1] = p[i] * F((i + 1) as u64);
    }
    r[n] = F(1) / p[n];
    for i in (0..n).rev() {
        r[i] = r[i + 1] * F((i + 1) as u64);
    }
    (p, r)
}

fn main() {
    input! {
        n : usize,
        e : [(Usize1, Usize1); n-1]
    }

    let (pos, neg) = gen_factorial(n + 10);
    let binomial = |n: usize, r: usize| pos[n] * neg[r] * neg[n - r];

    #[derive(Clone, Copy, Debug)]
    struct DP(F, usize);

    let add = |l: &DP, r: &DP| DP(l.0 * r.0 * binomial(l.1 + r.1, r.1), l.1 + r.1);
    let sub = |l: &DP, r: &DP| DP(l.0 / (r.0 * binomial(l.1, l.1 - r.1)), l.1 - r.1);
    let add_root = |x: &DP| DP(x.0, x.1 + 1);

    let tree = kyopro_lib::tree::Tree::new_with_edge(&e);
    let mut dp = vec![DP(F(1), 0); n];
    tree.dfs(
        0,
        |_| DP(F(1), 0),
        |_, _| {},
        |s: &mut DP, x| {
            *s = add(s, &add_root(&x));
        },
        |i, x| {
            dp[i] = x;
            x
        },
    );
    tree.dfs(
        0,
        |_| {},
        |r, n| {
            let d = sub(&dp[r], &add_root(&dp[n]));
            dp[n] = add(&dp[n], &add_root(&d));
        },
        |_, _| {},
        |_, _| {},
    );
    for x in dp {
        println!("{}", x.0);
    }
}
*/

fn main() {
    let exe = "/tmp/binC7582F57";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";