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:
/*
#![allow(unused_mut)]
#![allow(bare_trait_objects)]
#![allow(unused_imports)]
#![allow(unused_macros)]
// #![allow(dead_code)]

// https://github.com/tanzaku/rust-procon-lib
#[macro_use]
extern crate rust_procon_lib;

use rust_procon_lib::modcomb::*;
use rust_procon_lib::modint::*;
use rust_procon_lib::tree::*;
use rust_procon_lib::scanner::*;

make_modint!(MOD_1000000007);
make_modcomb!();

fn main() {
    let mut sc = Scanner::from_stdin();

    let n = sc.usize();
    let es = sc.edges(n - 1);
    let tree = Tree::new(n, &es);

    let comb = ModComb::new(n + 1);
    let mut size = vec![0; n];
    let mut val = vec![ModInt::from(1); n];
    for &v in tree.rdfs_order() {
        for &t in &tree.edges[v] {
            size[v] += size[t];
            val[v] = val[v] * val[t] * comb.comb(size[v], size[t]);
        }
        size[v] += 1;
    }

    let mut ans = vec![ModInt::from(0); n];
    for &v in tree.dfs_order() {
        if let Some(p) = tree.parent[v] {
            let x = ans[p] * (val[v] * comb.comb(n - 1, size[v])).inv();
            ans[v] += val[v] * x * comb.comb(n - 1, size[v] - 1);
        } else {
            ans[v] += val[v];
        }
    }

    ans.iter().for_each(|a| println!("{}", a));
}
*/

fn main() {
    let exe = "/tmp/bin1CFA824A";
    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>";