#[allow(unused_imports)]
use std::char::from_digit;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::fs::File;
#[allow(unused_imports)]
use std::io::prelude::*;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Stdin, Stdout, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;

type BoxResult<T> = Result<T, Box<std::error::Error>>;

const MOD: u64 = 1_000_000_000 + 7;

fn main() {
    let mut scanner = Scanner::new(stdin());
    let n = scanner.read::<usize>().unwrap();
    let mut adj = AdjacencyList::new(n);
    for _ in 0..(n - 1) {
        let (a, b) = scanner.read_two::<usize, usize>().unwrap();
        adj.add(a - 1, b - 1);
        adj.add(b - 1, a - 1);
    }
    let ans = solve(n, &adj);
    let mut writer = BufWriter::new(stdout());
    for i in 0..n {
        writeln!(&mut writer, "{}", ans[i]).unwrap();
    }
}

fn solve(n: usize, adj: &AdjacencyList) -> Vec<u64> {
    let (dp, sizes) = forward(n, adj);
    let values = backward(&dp, &sizes, n, adj);
    values
}

fn forward(n: usize, adj: &AdjacencyList) -> (Vec<u64>, Vec<usize>) {
    let mut dp = vec![0; n];
    let mut sizes = vec![0; n];
    let factors = (0..(n as u64))
        .scan(1, |state, val| {
            if val > 0 {
                *state = (*state * val) % MOD;
            }
            Some(*state)
        })
        .collect::<Vec<_>>();
    let mut stack = vec![(0, std::usize::MAX, false)];
    while stack.len() > 0 {
        let (crt, prv, visited) = stack.pop().unwrap();
        if visited {
            let mut val = 1;
            let mut size = 1;
            for &ch in adj[crt].iter() {
                if ch == prv {
                    continue;
                }
                size += sizes[ch];
                val = (val * dp[ch]) % MOD;
                val = (val * power(factors[sizes[ch]], MOD - 2, MOD)) % MOD;
            }
            val = (val * factors[size - 1]) % MOD;
            dp[crt] = val;
            sizes[crt] = size;
            continue;
        }
        stack.push((crt, prv, true));
        for &nxt in adj[crt].iter() {
            if nxt == prv {
                continue;
            }
            stack.push((nxt, crt, false));
        }
    }
    (dp, sizes)
}

fn backward(
    dp: &[u64],
    sizes: &[usize],
    n: usize,
    adj: &AdjacencyList,
) -> Vec<u64> {
    let mut values = vec![0; n];
    values[0] = dp[0];
    let mut stack = vec![(0, std::usize::MAX)];
    while stack.len() > 0 {
        let (crt, prv) = stack.pop().unwrap();
        for &nxt in adj[crt].iter() {
            if nxt == prv {
                continue;
            }
            stack.push((nxt, crt));
        }
        if crt == 0 {
            continue;
        }
        let mut val = values[prv];
        val = (val * sizes[crt] as u64) % MOD;
        val = (val * power((n - sizes[crt]) as u64, MOD - 2, MOD)) % MOD;
        values[crt] = val;
    }
    values
}

fn power(x: u64, mut k: u64, modulo: u64) -> u64 {
    let mut pows = vec![x];
    for i in 0..63 {
        let square = (pows[i] * pows[i]) % modulo;
        pows.push(square);
    }
    let mut pow = 1;
    for i in 0..64 {
        let flag = k & 1;
        k >>= 1;
        if flag == 1 {
            pow = (pow * pows[i]) % modulo;
        }
    }
    pow
}

pub struct AdjacencyList(Vec<Vec<usize>>);

impl AdjacencyList {
    pub fn new(n: usize) -> Self {
        AdjacencyList(vec![vec![]; n])
    }
    pub fn add(&mut self, i: usize, j: usize) {
        self.0[i].push(j);
    }
    pub fn len(&self) -> usize {
        self.0.len()
    }
}

impl std::ops::Index<usize> for AdjacencyList {
    type Output = Vec<usize>;
    fn index(&self, i: usize) -> &Self::Output {
        &self.0[i]
    }
}

#[allow(dead_code)]
struct Scanner<R> {
    reader: BufReader<R>,
    buffer: String,
}
impl<R> Scanner<R>
where
    R: Read,
{
    #[allow(dead_code)]
    fn new(inner: R) -> Scanner<R> {
        let reader = BufReader::new(inner);
        let buffer = String::new();
        Scanner {
            reader: reader,
            buffer: buffer,
        }
    }
    #[allow(dead_code)]
    fn with_capacity(capacity: usize, inner: R) -> Scanner<R> {
        let reader = BufReader::with_capacity(capacity, inner);
        let buffer = String::new();
        Scanner {
            reader: reader,
            buffer: buffer,
        }
    }
    #[allow(dead_code)]
    fn read_line(&mut self) -> BoxResult<String> {
        self.reader.read_line(&mut self.buffer)?;
        let cloned = self.buffer.trim().to_string();
        self.buffer.clear();
        Ok(cloned)
    }
    #[allow(dead_code)]
    fn read<T>(&mut self) -> BoxResult<T>
    where
        T: FromStr,
        T::Err: std::fmt::Debug,
        T::Err: std::error::Error,
        T::Err: 'static,
    {
        self.reader.read_line(&mut self.buffer)?;
        let parsed = self.buffer.trim().parse()?;
        self.buffer.clear();
        Ok(parsed)
    }
    #[allow(dead_code)]
    fn read_two<T, U>(&mut self) -> BoxResult<(T, U)>
    where
        T: FromStr,
        T: Copy,
        T::Err: std::fmt::Debug,
        T::Err: std::error::Error,
        T::Err: 'static,
        U: FromStr,
        U: Copy,
        U::Err: std::fmt::Debug,
        U::Err: std::error::Error,
        U::Err: 'static,
    {
        self.reader.read_line(&mut self.buffer)?;
        let (a, b) = {
            let params = self.buffer.trim().split_whitespace().collect::<Vec<_>>();
            let a = params[0].parse()?;
            let b = params[1].parse()?;
            (a, b)
        };
        self.buffer.clear();
        Ok((a, b))
    }
    #[allow(dead_code)]
    fn read_three<T>(&mut self) -> BoxResult<(T, T, T)>
    where
        T: FromStr,
        T: Copy,
        T::Err: std::fmt::Debug,
        T::Err: std::error::Error,
        T::Err: 'static,
    {
        let nums = self.read_vector()?;
        Ok((nums[0], nums[1], nums[2]))
    }
    #[allow(dead_code)]
    fn read_vector<T>(&mut self) -> BoxResult<Vec<T>>
    where
        T: FromStr,
        T::Err: std::fmt::Debug,
        T::Err: std::error::Error,
        T::Err: 'static,
    {
        self.reader.read_line(&mut self.buffer)?;
        let parsed_vec = self
            .buffer
            .trim()
            .split_whitespace()
            .map(|s| s.parse())
            .collect::<Result<Vec<_>, _>>()?;
        self.buffer.clear();
        Ok(parsed_vec)
    }
    #[allow(dead_code)]
    fn read_matrix<T>(&mut self, lines: usize) -> BoxResult<Vec<Vec<T>>>
    where
        T: FromStr,
        T::Err: std::fmt::Debug,
        T::Err: std::error::Error,
        T::Err: 'static,
    {
        let mut parsed_matrix = vec![];
        for _ in 0..lines {
            self.reader.read_line(&mut self.buffer)?;
            parsed_matrix.push(
                self.buffer
                    .trim()
                    .split_whitespace()
                    .map(|s| s.parse())
                    .collect::<Result<Vec<_>, _>>()?,
            );
            self.buffer.clear();
        }
        Ok(parsed_matrix)
    }
    #[allow(dead_code)]
    fn read_chars(&mut self) -> BoxResult<Vec<char>> {
        self.reader.read_line(&mut self.buffer)?;
        let chars = self.buffer.trim().chars().collect::<Vec<_>>();
        self.buffer.clear();
        Ok(chars)
    }
}


Measured memory_bytes: 33600