from functools import *

from collections import *

import sys

sys.setrecursionlimit(10**6)

input = sys.stdin.buffer.readline

 

M = 10**9+7



@lru_cache(maxsize=None)

def mod_inv(x):

  if x == 1:

    return 1

  return M // x * -mod_inv(M%x) % M



@lru_cache(maxsize=None)

def calc_subtree(v):

  ret = 1

  size = 1

  for child in Edge[v]:

    Edge[child].remove(v)

    r, s = calc_subtree(child)

    ret = ret * r % M

    size += s

  ret = ret * size % M

  return ret, size



ans = {}

def set_ans(v, a):

  ans[v] = a

  for child in Edge[v]:

    n = calc_subtree(child)[1]

    set_ans(child, ans[v] * n * mod_inv(N-n) % M)



N = int(eval(input()))

Edge = defaultdict(set)

fact = N

for i in range(1, N):

  fact = fact * i % M

  a, b = list(map(int, input().split()))

  Edge[a].add(b)

  Edge[b].add(a)



set_ans(1, mod_inv(calc_subtree(1)[0]) * fact % M)

for i in range(1, N+1):

  print((ans[i]))



from functools import *

from collections import *

import sys

sys.setrecursionlimit(10**6)

input = sys.stdin.buffer.readline

 

M = 10**9+7

N = int(eval(input()))



@lru_cache(maxsize=None)

def mod_inv(x):

  if x == 1:

    return 1

  return M // x * -mod_inv(M%x) % M



weight = [0]*(N+1)

size = [0]*(N+1)

def calc_subtree(v):

  W = 1

  S = 1

  for child in Edge[v]:

    Edge[child].remove(v)

    w, s = calc_subtree(child)

    W = W * w % M

    S += s

  weight[v] = W * S % M

  size[v] = S

  return weight[v], size[v]



ans = [0]*(N+1)

def set_ans(v, a):

  ans[v] = a

  for child in Edge[v]:

    n = size[child]

    set_ans(child, ans[v] * n * mod_inv(N-n) % M)



Edge = defaultdict(set)

fact = N

for i in range(1, N):

  fact = fact * i % M

  a, b = list(map(int, input().split()))

  Edge[a].add(b)

  Edge[b].add(a)

  

calc_subtree(1)

set_ans(1, mod_inv(weight[1]) * fact % M)

for i in range(1, N+1):

  print((ans[i]))



from functools import *
from collections import *
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
M = 10**9 + 7


@lru_cache(maxsize=None)
def mod_inv(x):
    if x == 1:
        return 1
    return M // x * -mod_inv(M % x) % M


@lru_cache(maxsize=None)
def calc_subtree(v):
    ret = 1
    size = 1
    for child in Edge[v]:
        Edge[child].remove(v)
        r, s = calc_subtree(child)
        ret = ret * r % M
        size += s
    ret = ret * size % M
    return ret, size


ans = {}


def set_ans(v, a):
    ans[v] = a
    for child in Edge[v]:
        n = calc_subtree(child)[1]
        set_ans(child, ans[v] * n * mod_inv(N - n) % M)


N = int(eval(input()))
Edge = defaultdict(set)
fact = N
for i in range(1, N):
    fact = fact * i % M
    a, b = list(map(int, input().split()))
    Edge[a].add(b)
    Edge[b].add(a)
set_ans(1, mod_inv(calc_subtree(1)[0]) * fact % M)
for i in range(1, N + 1):
    print((ans[i]))

from functools import *
from collections import *
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
M = 10**9 + 7
N = int(eval(input()))


@lru_cache(maxsize=None)
def mod_inv(x):
    if x == 1:
        return 1
    return M // x * -mod_inv(M % x) % M


weight = [0] * (N + 1)
size = [0] * (N + 1)


def calc_subtree(v):
    W = 1
    S = 1
    for child in Edge[v]:
        Edge[child].remove(v)
        w, s = calc_subtree(child)
        W = W * w % M
        S += s
    weight[v] = W * S % M
    size[v] = S
    return weight[v], size[v]


ans = [0] * (N + 1)


def set_ans(v, a):
    ans[v] = a
    for child in Edge[v]:
        n = size[child]
        set_ans(child, ans[v] * n * mod_inv(N - n) % M)


Edge = defaultdict(set)
fact = N
for i in range(1, N):
    fact = fact * i % M
    a, b = list(map(int, input().split()))
    Edge[a].add(b)
    Edge[b].add(a)
calc_subtree(1)
set_ans(1, mod_inv(weight[1]) * fact % M)
for i in range(1, N + 1):
    print((ans[i]))

+N = int(eval(input())) -@lru_cache(maxsize=None) +weight = [0] * (N + 1) +size = [0] * (N + 1) + + -    ret = 1 -    size = 1 +    W = 1 +    S = 1 -        r, s = calc_subtree(child) -        ret = ret * r % M -        size += s -    ret = ret * size % M -    return ret, size +        w, s = calc_subtree(child) +        W = W * w % M +        S += s +    weight[v] = W * S % M +    size[v] = S +    return weight[v], size[v] -ans = {} +ans = [0] * (N + 1) -        n = calc_subtree(child)[1] +        n = size[child] -N = int(eval(input())) -set_ans(1, mod_inv(calc_subtree(1)[0]) * fact % M) +calc_subtree(1) +set_ans(1, mod_inv(weight[1]) * fact % M)