class Factorial():
    def __init__(self, n, mod):
        self.mod = mod
        self.factorial = [0 for _ in range(n + 1)]
        self.inv = [0 for _ in range(n + 1)]
        self.factorial[0] = 1
        self.inv[0] = 1
        for i in range(n):
            self.factorial[i + 1] = self.factorial[i] * (i + 1) % mod
        self.inv[n] = pow(self.factorial[n], mod - 2, mod)
        for i in range(n)[::-1]:
            self.inv[i] = self.inv[i + 1] * (i + 1) % mod

    def fact(self, m):
        return self.factorial[m]

    def invfact(self, m):
        return self.inv[m]

import sys
input = sys.stdin.readline

MOD = 1000000007

N = int(input())
E = [tuple(map(int, input().split())) for _ in range(N - 1)]

tree = [[] for _ in range(N)]

for e in E:
    tree[e[0] - 1].append(e[1] - 1)
    tree[e[1] - 1].append(e[0] - 1)

visited = [0 for _ in range(N)]
visited[0] = 1

parent = [None for _ in range(N)]
parent[0] = -1

order = []
order.append(0)

stack = [0]

while stack:
    node = stack.pop()
    for adj in tree[node]:
        if not visited[adj]:
            visited[adj] = 1
            parent[adj] = node
            order.append(adj)
            stack.append(adj)

dp = [[1, 1] for _ in range(N)]
cum_l = [[1, 0] for _ in range(N)]
cum_r = [[1, 0] for _ in range(N)]

F = Factorial(N + 1, MOD)

for node in order[::-1]:
    dp_node = [1, 1]
    for adj in tree[node]:
        if parent[adj] == node:
            cum_l[adj][0] = dp_node[0]
            cum_l[adj][1] = dp_node[1]
            dp_node[1] += dp[adj][1]
            dp_node[0] *= dp[adj][0]
            dp_node[0] *= F.invfact(dp[adj][1])
            dp_node[0] *= F.fact(dp_node[1] - 1)
            dp_node[0] *= F.invfact(dp_node[1] - dp[adj][1] - 1)
            dp_node[0] %= MOD

    dp_node = [1, 1]
    for adj in tree[node][::-1]:
        if parent[adj] == node:
            cum_r[adj][0] = dp_node[0]
            cum_r[adj][1] = dp_node[1]
            dp_node[1] += dp[adj][1]
            dp_node[0] *= dp[adj][0]
            dp_node[0] *= F.invfact(dp[adj][1])
            dp_node[0] *= F.fact(dp_node[1] - 1)
            dp_node[0] *= F.invfact(dp_node[1] - dp[adj][1] - 1)
            dp_node[0] %= MOD

    dp[node][0] = dp_node[0]
    dp[node][1] = dp_node[1]

dp_inv = [[1, 0] for _ in range(N)]

for node in order:
    if node == 0:
        continue

    merged = [1, 0]
    merged[1] = cum_l[node][1] + cum_r[node][1] - 1
    merged[0] *= cum_l[node][0] * F.invfact(cum_l[node][1] - 1)
    merged[0] *= cum_r[node][0] * F.invfact(cum_r[node][1] - 1)
    merged[0] *= F.fact(merged[1] - 1)
    merged[0] %= MOD

    par = parent[node]
    dp_inv[node][0] = merged[0]
    dp_inv[node][1] = merged[1]
    dp_inv[node][1] += dp_inv[par][1]
    dp_inv[node][0] *= dp_inv[par][0]
    dp_inv[node][0] *= F.invfact(dp_inv[par][1])
    dp_inv[node][0] *= F.fact(dp_inv[node][1] - 1)
    dp_inv[node][0] *= F.invfact(dp_inv[node][1] - dp_inv[par][1] - 1)
    dp_inv[node][0] %= MOD

    dp_node = [1, 1]
    dp_node[0] = dp[node][0]
    dp_node[1] = dp[node][1]
    dp_node[1] += dp_inv[node][1]
    dp_node[0] *= dp_inv[node][0]
    dp_node[0] *= F.invfact(dp_inv[node][1])
    dp_node[0] *= F.fact(dp_node[1] - 1)
    dp_node[0] *= F.invfact(dp_node[1] - dp_inv[node][1] - 1)
    dp_node[0] %= MOD

    dp[node][0] = dp_node[0]
    dp[node][1] = dp_node[1]

res = []

for i in range(N):
    res.append(dp[i][0])

print('\n'.join(map(str, res)))

Measured memory_bytes: 284868