import sys

input = sys.stdin.readline

from collections import deque



mod = 10 ** 9 + 7

N = int(input())

X = [[] for i in range(N)]

for i in range(N-1):

    x, y = map(int, input().split())

    X[x-1].append(y-1)

    X[y-1].append(x-1)



P = [-1] * N

Q = deque([0])

R = []

while Q:

    i = deque.popleft(Q)

    R.append(i)

    for a in X[i]:

        if a != P[i]:

            P[a] = i

            X[a].remove(i)

            deque.append(Q, a)



##### Settings

unit = 1

merge = lambda a, b: a * b % mod

adj_bu = lambda a, i: a * inv(SIZE[i]) % mod

adj_td = lambda a, i, p: a * inv(N-SIZE[i]) % mod

adj_fin = lambda a, i: a * fa[N-1] % mod

#####



nn = 200200

mod = 10**9+7



fa = [1] * (nn+1)

fainv = [1] * (nn+1)

for i in range(nn):

    fa[i+1] = fa[i] * (i+1) % mod

fainv[-1] = pow(fa[-1], mod-2, mod)

for i in range(nn)[::-1]:

    fainv[i] = fainv[i+1] * (i+1) % mod



inv = lambda i: fainv[i] * fa[i-1] % mod



SIZE = [1] * N

for i in reversed(R[1:]):

    SIZE[P[i]] += SIZE[i]



ME = [unit] * N

XX = [0] * N

TD = [unit] * N

for i in reversed(R[1:]):

    XX[i] = adj_bu(ME[i], i)

    p = P[i]

    ME[p] = merge(ME[p], XX[i])

XX[R[0]] = adj_fin(ME[R[0]], R[0])



for i in R:

    ac = TD[i]

    for j in X[i]:

        TD[j] = ac

        ac = merge(ac, XX[j])

    ac = unit

    for j in reversed(X[i]):

        TD[j] = adj_td(merge(TD[j], ac), j, i)

        ac = merge(ac, XX[j])

        XX[j] = adj_fin(merge(ME[j], TD[j]), j)



print(*XX, sep = "\n")

import sys

input = sys.stdin.readline

from collections import deque



mod = 10 ** 9 + 7

N = int(input())

X = [[] for i in range(N)]

for i in range(N-1):

    x, y = map(int, input().split())

    X[x-1].append(y-1)

    X[y-1].append(x-1)



P = [-1] * N

Q = deque([0])

R = []

while Q:

    i = deque.popleft(Q)

    R.append(i)

    for a in X[i]:

        if a != P[i]:

            P[a] = i

            X[a].remove(i)

            deque.append(Q, a)



##### Settings

unit = 1

merge = lambda a, b: a * b % mod

adj_bu = lambda a, i: a * inv(SIZE[i]) % mod

adj_td = lambda a, i, p: a * inv(N-SIZE[i]) % mod

adj_fin = lambda a, i: a * fa[N-1] % mod

#####



nn = 200200

mod = 10**9+7



fa = [1] * (nn+1)

fainv = [1] * (nn+1)

for i in range(nn):

    fa[i+1] = fa[i] * (i+1) % mod

fainv[-1] = pow(fa[-1], mod-2, mod)

for i in range(nn)[::-1]:

    fainv[i] = fainv[i+1] * (i+1) % mod



inv = lambda i: fainv[i] * fa[i-1] % mod



SIZE = [1] * N

for i in R[1:][::-1]:

    SIZE[P[i]] += SIZE[i]



ME = [unit] * N

XX = [0] * N

TD = [unit] * N

for i in R[1:][::-1]:

    XX[i] = adj_bu(ME[i], i)

    p = P[i]

    ME[p] = merge(ME[p], XX[i])

XX[R[0]] = adj_fin(ME[R[0]], R[0])



for i in R:

    ac = TD[i]

    for j in X[i]:

        TD[j] = ac

        ac = merge(ac, XX[j])

    ac = unit

    for j in X[i][::-1]:

        TD[j] = adj_td(merge(TD[j], ac), j, i)

        ac = merge(ac, XX[j])

        XX[j] = adj_fin(merge(ME[j], TD[j]), j)



print(*XX, sep = "\n")

import sys

input = sys.stdin.readline
from collections import deque

mod = 10**9 + 7
N = int(input())
X = [[] for i in range(N)]
for i in range(N - 1):
    x, y = map(int, input().split())
    X[x - 1].append(y - 1)
    X[y - 1].append(x - 1)
P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)
##### Settings
unit = 1
merge = lambda a, b: a * b % mod
adj_bu = lambda a, i: a * inv(SIZE[i]) % mod
adj_td = lambda a, i, p: a * inv(N - SIZE[i]) % mod
adj_fin = lambda a, i: a * fa[N - 1] % mod
#####
nn = 200200
mod = 10**9 + 7
fa = [1] * (nn + 1)
fainv = [1] * (nn + 1)
for i in range(nn):
    fa[i + 1] = fa[i] * (i + 1) % mod
fainv[-1] = pow(fa[-1], mod - 2, mod)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i + 1] * (i + 1) % mod
inv = lambda i: fainv[i] * fa[i - 1] % mod
SIZE = [1] * N
for i in reversed(R[1:]):
    SIZE[P[i]] += SIZE[i]
ME = [unit] * N
XX = [0] * N
TD = [unit] * N
for i in reversed(R[1:]):
    XX[i] = adj_bu(ME[i], i)
    p = P[i]
    ME[p] = merge(ME[p], XX[i])
XX[R[0]] = adj_fin(ME[R[0]], R[0])
for i in R:
    ac = TD[i]
    for j in X[i]:
        TD[j] = ac
        ac = merge(ac, XX[j])
    ac = unit
    for j in reversed(X[i]):
        TD[j] = adj_td(merge(TD[j], ac), j, i)
        ac = merge(ac, XX[j])
        XX[j] = adj_fin(merge(ME[j], TD[j]), j)
print(*XX, sep="\n")

import sys

input = sys.stdin.readline
from collections import deque

mod = 10**9 + 7
N = int(input())
X = [[] for i in range(N)]
for i in range(N - 1):
    x, y = map(int, input().split())
    X[x - 1].append(y - 1)
    X[y - 1].append(x - 1)
P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)
##### Settings
unit = 1
merge = lambda a, b: a * b % mod
adj_bu = lambda a, i: a * inv(SIZE[i]) % mod
adj_td = lambda a, i, p: a * inv(N - SIZE[i]) % mod
adj_fin = lambda a, i: a * fa[N - 1] % mod
#####
nn = 200200
mod = 10**9 + 7
fa = [1] * (nn + 1)
fainv = [1] * (nn + 1)
for i in range(nn):
    fa[i + 1] = fa[i] * (i + 1) % mod
fainv[-1] = pow(fa[-1], mod - 2, mod)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i + 1] * (i + 1) % mod
inv = lambda i: fainv[i] * fa[i - 1] % mod
SIZE = [1] * N
for i in R[1:][::-1]:
    SIZE[P[i]] += SIZE[i]
ME = [unit] * N
XX = [0] * N
TD = [unit] * N
for i in R[1:][::-1]:
    XX[i] = adj_bu(ME[i], i)
    p = P[i]
    ME[p] = merge(ME[p], XX[i])
XX[R[0]] = adj_fin(ME[R[0]], R[0])
for i in R:
    ac = TD[i]
    for j in X[i]:
        TD[j] = ac
        ac = merge(ac, XX[j])
    ac = unit
    for j in X[i][::-1]:
        TD[j] = adj_td(merge(TD[j], ac), j, i)
        ac = merge(ac, XX[j])
        XX[j] = adj_fin(merge(ME[j], TD[j]), j)
print(*XX, sep="\n")

-for i in reversed(R[1:]): +for i in R[1:][::-1]: -for i in reversed(R[1:]): +for i in R[1:][::-1]: -    for j in reversed(X[i]): +    for j in X[i][::-1]: