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 itertools 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):

  return 1 if x == 1 else M // x * -mod_inv(M%x) % M



Weight = [0]*(N+1)

Size = [0]*(N+1)

def calc_subtree(v):

  W, S = 1, 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 calc_ans(v, a):

  Ans[v] = a

  for child in Edge[v]:

    n = Size[child]

    calc_ans(child, Ans[v] * n * mod_inv(N-n) % M)



Edge = [set() for i in range(N+1)]

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)

calc_ans(1, mod_inv(Weight[1]) * fact % M)



for a in islice(Ans, 1, None):

  print(a)



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 itertools 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):
    return 1 if x == 1 else M // x * -mod_inv(M % x) % M


Weight = [0] * (N + 1)
Size = [0] * (N + 1)


def calc_subtree(v):
    W, S = 1, 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 calc_ans(v, a):
    Ans[v] = a
    for child in Edge[v]:
        n = Size[child]
        calc_ans(child, Ans[v] * n * mod_inv(N - n) % M)


Edge = [set() for i in range(N + 1)]
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)
calc_ans(1, mod_inv(Weight[1]) * fact % M)
for a in islice(Ans, 1, None):
    print(a)

-from collections import * +from itertools import * -    if x == 1: -        return 1 -    return M // x * -mod_inv(M % x) % M +    return 1 if x == 1 else M // x * -mod_inv(M % x) % M -weight = [0] * (N + 1) -size = [0] * (N + 1) +Weight = [0] * (N + 1) +Size = [0] * (N + 1) -    W = 1 -    S = 1 +    W, S = 1, 1 -    weight[v] = W * S % M -    size[v] = S -    return weight[v], size[v] +    Weight[v] = W * S % M +    Size[v] = S +    return Weight[v], Size[v] -ans = [0] * (N + 1) +Ans = [0] * (N + 1) -def set_ans(v, a): -    ans[v] = a +def calc_ans(v, a): +    Ans[v] = a -        n = size[child] -        set_ans(child, ans[v] * n * mod_inv(N - n) % M) +        n = Size[child] +        calc_ans(child, Ans[v] * n * mod_inv(N - n) % M) -Edge = defaultdict(set) +Edge = [set() for i in range(N + 1)] -set_ans(1, mod_inv(weight[1]) * fact % M) -for i in range(1, N + 1): -    print((ans[i])) +calc_ans(1, mod_inv(Weight[1]) * fact % M) +for a in islice(Ans, 1, None): +    print(a)