from itertools import accumulate



MOD = 10 ** 9 + 7

table_len = 2 * 10 ** 5 + 10



fac = [1, 1]

for i in range(2, table_len):

    fac.append(fac[-1] * i % MOD)

    

finv = [0] * table_len

finv[-1] = pow(fac[-1], MOD - 2, MOD)

for i in range(table_len-1, -1, -1):

    finv[i-1] = finv[i] * i % MOD





N = int(eval(input()))



adj = [[] for _ in range(N+1)]



for _ in range(N-1):

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

    adj[a].append(b)

    adj[b].append(a)





dfs_order = []

parent = [0] * (N+1)

root = 1

stack = [root]

while stack:

    node = stack.pop()

    dfs_order.append(node)

    for child in adj[node]:

        if child != parent[node]:

            parent[child] = node

            stack.append(child)





dp1_size = [1] * (N+1)

for node in reversed(dfs_order):

    for child in adj[node]:

        if child != parent[node]:

            dp1_size[node] += dp1_size[child]



dp2_size = [0] * (N+1)

for node in dfs_order:

    around = [dp1_size[next_node] if next_node != parent[node] else dp2_size[node] for next_node in adj[node]]

    from_left = [0] + list(accumulate(around))[:-1]

    from_right = list(accumulate(reversed(around)))[-2::-1] + [0]

    without = [l + r for l, r in zip(from_left, from_right)]

    for next_node, value in zip(adj[node], without):

        if next_node != parent[node]:

            dp2_size[next_node] += value + 1



dp1 = [1] * (N+1)

for node in reversed(dfs_order):

    s = 0

    for child in adj[node]:

        if child != parent[node]:

            s += dp1_size[child]

            dp1[node] *= dp1[child]

            dp1[node] %= MOD

            dp1[node] *= finv[dp1_size[child]]

            dp1[node] %= MOD

    dp1[node] *= fac[s]

    dp1[node] %= MOD



def func(t1, t2):

    size1, value1 = t1

    size2, value2 = t2

    size = size1 + size2

    comb = fac[size] * finv[size1] * finv[size2] % MOD

    value = comb * value1 * value2 % MOD

    return (size, value)

        

dp2 = [1] * (N+1)

for node in dfs_order:

    around_size = [dp1_size[next_node] if next_node != parent[node] else dp2_size[node] for next_node in adj[node]]

    around = [dp1[next_node] if next_node != parent[node] else dp2[node] for next_node in adj[node]]

    

    from_left = [(0, 1)] + list(accumulate(list(zip(around_size, around)), func))[:-1]

    from_right = list(accumulate(reversed(list(zip(around_size, around))), func))[-2::-1] + [(0, 1)]

    without = [func(l, r) for l, r in zip(from_left, from_right)]

    for next_node, (_, value) in zip(adj[node], without):

        if next_node != parent[node]:

            dp2[next_node] = value



for size1, val1, size2, val2 in zip(dp1_size[1:], dp1[1:], dp2_size[1:], dp2[1:]):

    print((func((size1 - 1, val1), (size2, val2))[1]))
from itertools import accumulate



MOD = 10 ** 9 + 7

table_len = 2 * 10 ** 5 + 10



fac = [1, 1]

for i in range(2, table_len):

    fac.append(fac[-1] * i % MOD)

    

finv = [0] * table_len

finv[-1] = pow(fac[-1], MOD - 2, MOD)

for i in range(table_len-1, -1, -1):

    finv[i-1] = finv[i] * i % MOD





N = int(eval(input()))



adj = [[] for _ in range(N+1)]



for _ in range(N-1):

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

    adj[a].append(b)

    adj[b].append(a)





dfs_order = []

parent = [0] * (N+1)

root = 1

stack = [root]

while stack:

    node = stack.pop()

    dfs_order.append(node)

    for child in adj[node]:

        if child != parent[node]:

            parent[child] = node

            stack.append(child)



def func(t1, t2):

    size1, value1 = t1

    size2, value2 = t2

    size = size1 + size2

    comb = fac[size] * finv[size1] * finv[size2] % MOD

    value = comb * value1 * value2 % MOD

    return (size, value)

       

dp1 = [(0, 1)] * (N+1)

for node in reversed(dfs_order):

    for child in adj[node]:

        if child != parent[node]:

            dp1[node] = func(dp1[node], dp1[child])

    dp1[node] = (dp1[node][0] + 1, dp1[node][1])



dp2 = [(0, 1)] * (N+1)

for node in dfs_order:

    around = [dp1[next_node] if next_node != parent[node] else dp2[node] for next_node in adj[node]]

    from_left = [(0, 1)] + list(accumulate(around, func))[:-1]

    from_right = list(accumulate(reversed(around), func))[-2::-1] + [(0, 1)]

    without = [func(l, r) for l, r in zip(from_left, from_right)]

    for next_node, t in zip(adj[node], without):

        if next_node != parent[node]:

            dp2[next_node] = (t[0] + 1, t[1])



for t1, t2 in zip(dp1[1:], dp2[1:]):

    print((func((t1[0] - 1, t1[1]), t2)[1]))
from itertools import accumulate

MOD = 10**9 + 7
table_len = 2 * 10**5 + 10
fac = [1, 1]
for i in range(2, table_len):
    fac.append(fac[-1] * i % MOD)
finv = [0] * table_len
finv[-1] = pow(fac[-1], MOD - 2, MOD)
for i in range(table_len - 1, -1, -1):
    finv[i - 1] = finv[i] * i % MOD
N = int(eval(input()))
adj = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    adj[a].append(b)
    adj[b].append(a)
dfs_order = []
parent = [0] * (N + 1)
root = 1
stack = [root]
while stack:
    node = stack.pop()
    dfs_order.append(node)
    for child in adj[node]:
        if child != parent[node]:
            parent[child] = node
            stack.append(child)
dp1_size = [1] * (N + 1)
for node in reversed(dfs_order):
    for child in adj[node]:
        if child != parent[node]:
            dp1_size[node] += dp1_size[child]
dp2_size = [0] * (N + 1)
for node in dfs_order:
    around = [
        dp1_size[next_node] if next_node != parent[node] else dp2_size[node]
        for next_node in adj[node]
    ]
    from_left = [0] + list(accumulate(around))[:-1]
    from_right = list(accumulate(reversed(around)))[-2::-1] + [0]
    without = [l + r for l, r in zip(from_left, from_right)]
    for next_node, value in zip(adj[node], without):
        if next_node != parent[node]:
            dp2_size[next_node] += value + 1
dp1 = [1] * (N + 1)
for node in reversed(dfs_order):
    s = 0
    for child in adj[node]:
        if child != parent[node]:
            s += dp1_size[child]
            dp1[node] *= dp1[child]
            dp1[node] %= MOD
            dp1[node] *= finv[dp1_size[child]]
            dp1[node] %= MOD
    dp1[node] *= fac[s]
    dp1[node] %= MOD


def func(t1, t2):
    size1, value1 = t1
    size2, value2 = t2
    size = size1 + size2
    comb = fac[size] * finv[size1] * finv[size2] % MOD
    value = comb * value1 * value2 % MOD
    return (size, value)


dp2 = [1] * (N + 1)
for node in dfs_order:
    around_size = [
        dp1_size[next_node] if next_node != parent[node] else dp2_size[node]
        for next_node in adj[node]
    ]
    around = [
        dp1[next_node] if next_node != parent[node] else dp2[node]
        for next_node in adj[node]
    ]
    from_left = [(0, 1)] + list(accumulate(list(zip(around_size, around)), func))[:-1]
    from_right = list(accumulate(reversed(list(zip(around_size, around))), func))[
        -2::-1
    ] + [(0, 1)]
    without = [func(l, r) for l, r in zip(from_left, from_right)]
    for next_node, (_, value) in zip(adj[node], without):
        if next_node != parent[node]:
            dp2[next_node] = value
for size1, val1, size2, val2 in zip(dp1_size[1:], dp1[1:], dp2_size[1:], dp2[1:]):
    print((func((size1 - 1, val1), (size2, val2))[1]))

from itertools import accumulate

MOD = 10**9 + 7
table_len = 2 * 10**5 + 10
fac = [1, 1]
for i in range(2, table_len):
    fac.append(fac[-1] * i % MOD)
finv = [0] * table_len
finv[-1] = pow(fac[-1], MOD - 2, MOD)
for i in range(table_len - 1, -1, -1):
    finv[i - 1] = finv[i] * i % MOD
N = int(eval(input()))
adj = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    adj[a].append(b)
    adj[b].append(a)
dfs_order = []
parent = [0] * (N + 1)
root = 1
stack = [root]
while stack:
    node = stack.pop()
    dfs_order.append(node)
    for child in adj[node]:
        if child != parent[node]:
            parent[child] = node
            stack.append(child)


def func(t1, t2):
    size1, value1 = t1
    size2, value2 = t2
    size = size1 + size2
    comb = fac[size] * finv[size1] * finv[size2] % MOD
    value = comb * value1 * value2 % MOD
    return (size, value)


dp1 = [(0, 1)] * (N + 1)
for node in reversed(dfs_order):
    for child in adj[node]:
        if child != parent[node]:
            dp1[node] = func(dp1[node], dp1[child])
    dp1[node] = (dp1[node][0] + 1, dp1[node][1])
dp2 = [(0, 1)] * (N + 1)
for node in dfs_order:
    around = [
        dp1[next_node] if next_node != parent[node] else dp2[node]
        for next_node in adj[node]
    ]
    from_left = [(0, 1)] + list(accumulate(around, func))[:-1]
    from_right = list(accumulate(reversed(around), func))[-2::-1] + [(0, 1)]
    without = [func(l, r) for l, r in zip(from_left, from_right)]
    for next_node, t in zip(adj[node], without):
        if next_node != parent[node]:
            dp2[next_node] = (t[0] + 1, t[1])
for t1, t2 in zip(dp1[1:], dp2[1:]):
    print((func((t1[0] - 1, t1[1]), t2)[1]))

-dp1_size = [1] * (N + 1) -for node in reversed(dfs_order): -    for child in adj[node]: -        if child != parent[node]: -            dp1_size[node] += dp1_size[child] -dp2_size = [0] * (N + 1) -for node in dfs_order: -    around = [ -        dp1_size[next_node] if next_node != parent[node] else dp2_size[node] -        for next_node in adj[node] -    ] -    from_left = [0] + list(accumulate(around))[:-1] -    from_right = list(accumulate(reversed(around)))[-2::-1] + [0] -    without = [l + r for l, r in zip(from_left, from_right)] -    for next_node, value in zip(adj[node], without): -        if next_node != parent[node]: -            dp2_size[next_node] += value + 1 -dp1 = [1] * (N + 1) -for node in reversed(dfs_order): -    s = 0 -    for child in adj[node]: -        if child != parent[node]: -            s += dp1_size[child] -            dp1[node] *= dp1[child] -            dp1[node] %= MOD -            dp1[node] *= finv[dp1_size[child]] -            dp1[node] %= MOD -    dp1[node] *= fac[s] -    dp1[node] %= MOD -dp2 = [1] * (N + 1) +dp1 = [(0, 1)] * (N + 1) +for node in reversed(dfs_order): +    for child in adj[node]: +        if child != parent[node]: +            dp1[node] = func(dp1[node], dp1[child]) +    dp1[node] = (dp1[node][0] + 1, dp1[node][1]) +dp2 = [(0, 1)] * (N + 1) -    around_size = [ -        dp1_size[next_node] if next_node != parent[node] else dp2_size[node] -        for next_node in adj[node] -    ] -    from_left = [(0, 1)] + list(accumulate(list(zip(around_size, around)), func))[:-1] -    from_right = list(accumulate(reversed(list(zip(around_size, around))), func))[ -        -2::-1 -    ] + [(0, 1)] +    from_left = [(0, 1)] + list(accumulate(around, func))[:-1] +    from_right = list(accumulate(reversed(around), func))[-2::-1] + [(0, 1)] -    for next_node, (_, value) in zip(adj[node], without): +    for next_node, t in zip(adj[node], without): -            dp2[next_node] = value -for size1, val1, size2, val2 in zip(dp1_size[1:], dp1[1:], dp2_size[1:], dp2[1:]): -    print((func((size1 - 1, val1), (size2, val2))[1])) +            dp2[next_node] = (t[0] + 1, t[1]) +for t1, t2 in zip(dp1[1:], dp2[1:]): +    print((func((t1[0] - 1, t1[1]), t2)[1]))