CodeEff/ECCO huggingface dataset:
# Original solution
def main():  
  from collections import deque
  N = int(eval(input()))
  ab = [list(map(int,input().split())) for _ in range(N-1)]
  mod = 10**9+7
  fact = [1]*(N+1)
  fact_inv = [1]*(N+1)
  for i in range(1,N+1):
    fact[i] = (fact[i-1]*i)%mod
    fact_inv[i] = pow(fact[i], mod-2, mod)

  g = [deque([]) for _ in range(N+1)]
  for a,b in ab:
    g[a].append(b)
    g[b].append(a)

  parents = [0]*(N+1)
  q = deque([])
  s = deque([1])
  while s:
    x = s.pop()
    q.append(x)
    for y in g[x]:
      if y==parents[x]:
        continue
      else:
        parents[y] = x
        s.append(y)

  q = list(q)
  size_forward = [0]*(N+1)
  dp_forward = [1]*(N+1)
  for i in q[::-1]:
    p = parents[i]
    s = size_forward[i] + 1
    size_forward[p] += s
    dp_forward[i] *= fact[size_forward[i]]
    dp_forward[p] *= dp_forward[i] * fact_inv[s]
    dp_forward[p] %= mod

  size_back = [N-1-i for i in size_forward]
  dp_back = [1]*(N+1)
  for i in q[1:]:
    p = parents[i]
    x = dp_back[p]
    x *= fact_inv[size_back[p]]
    x *= dp_forward[p]
    x *= fact_inv[size_forward[p]]
    x *= fact[size_forward[i]+1]
    x *= pow(dp_forward[i],mod-2,mod)
    x *= fact[size_back[i]-1]
    dp_back[i] = x % mod

  for a,b,c,d in zip(size_forward[1:], dp_forward[1:], size_back[1:], dp_back[1:]):
    ans = b * d * fact[a+c] * fact_inv[a] * fact_inv[c]
    ans %= mod
    print(ans)
    
main()

# Optimized solution
from collections import deque
N = int(eval(input()))
ab = [list(map(int,input().split())) for _ in range(N-1)]
mod = 10**9+7
fact = [1]*(N+1)
fact_inv = [1]*(N+1)
for i in range(1,N+1):
  fact[i] = (fact[i-1]*i)%mod
  
fact_inv[-1] = pow(fact[-1], mod-2, mod)
for i in range(N,0,-1):
  fact_inv[i-1] = fact_inv[i] * i % mod

g = [deque([]) for _ in range(N+1)]
for a,b in ab:
  g[a].append(b)
  g[b].append(a)
  
parents = [0]*(N+1)
q = deque([])
s = deque([1])
while s:
  x = s.pop()
  q.append(x)
  for y in g[x]:
    if y==parents[x]:
      continue
    else:
      parents[y] = x
      s.append(y)
      
q = list(q)
size_forward = [0]*(N+1)
dp_forward = [1]*(N+1)
for i in q[::-1]:
  p = parents[i]
  s = size_forward[i] + 1
  size_forward[p] += s
  dp_forward[i] *= fact[size_forward[i]]
  dp_forward[p] *= dp_forward[i] * fact_inv[s]
  dp_forward[p] %= mod
  
size_back = [N-1-i for i in size_forward]
dp_back = [1]*(N+1)
for i in q[1:]:
  p = parents[i]
  x = dp_back[p]
  x *= fact_inv[size_back[p]]
  x *= dp_forward[p]
  x *= fact_inv[size_forward[p]]
  x *= fact[size_forward[i]+1]
  x *= pow(dp_forward[i],mod-2,mod)
  x *= fact[size_back[i]-1]
  dp_back[i] = x % mod
  
for a,b,c,d in zip(size_forward[1:], dp_forward[1:], size_back[1:], dp_back[1:]):
  ans = b * d * fact[a+c] * fact_inv[a] * fact_inv[c]
  ans %= mod
  print(ans)
# Original solution
import sys
input = sys.stdin.readline

N = int(eval(input()))
vec = [[] for _ in range(N)]
for _ in range(N - 1) :
  a, b = list(map(int, input().split()))
  vec[a - 1].append(b - 1)
  vec[b - 1].append(a - 1)

mod = 10 ** 9 + 7

fac = [1]
for i in range(1, N + 1) :
  fac.append(fac[-1] * i)

inv = [pow(fac[-1], mod - 2, mod)]
for i in range(N, 0, -1) :
  inv.append(inv[-1] * i % mod)
inv = inv[::-1]

def comb(n, r) :
  return fac[n] * inv[n-r] * inv[r] % mod

pattern = [1] * N
subtree = [0] * N

# DFS
stack = [(0, -1, 0)]
while stack :
  cur, pre, op = stack.pop()
  
  if op == 0 :
    stack.append((cur, pre, 1))
    for nex in vec[cur] :
      if nex == pre : continue
      stack.append((nex, cur, 0))
  else :
    for nex in vec[cur] :
      pattern[cur] *= pattern[nex] * comb(subtree[cur] + subtree[nex], subtree[nex]) % mod
      pattern[cur] %= mod
      subtree[cur] += subtree[nex]
    subtree[cur] += 1

# BFS
q = [(0, -1)]
while q :
  cur, pre = q.pop()
  for nex in vec[cur] :
    if nex == pre : continue
    pattern[nex] = pattern[cur] * subtree[nex] * inv[N - subtree[nex]] * fac[N - subtree[nex] - 1] % mod
    q.append((nex, cur))
  
for i in range(N) :
  print((pattern[i]))

# Optimized solution
import sys
input = sys.stdin.readline

N = int(eval(input()))
vec = [[] for _ in range(N)]
for _ in range(N - 1) :
  a, b = list(map(int, input().split()))
  vec[a - 1].append(b - 1)
  vec[b - 1].append(a - 1)

mod = 10 ** 9 + 7

fac = [1]
for i in range(1, N + 1) :
  fac.append(fac[-1] * i % mod)

inv = [pow(fac[-1], mod - 2, mod)]
for i in range(N, 0, -1) :
  inv.append(inv[-1] * i % mod)
inv = inv[::-1]

def comb(n, r) :
  return fac[n] * inv[n-r] * inv[r] % mod

pattern = [1] * N
subtree = [0] * N

# DFS
stack = [(0, -1, 0)]
while stack :
  cur, pre, op = stack.pop()
  
  if op == 0 :
    stack.append((cur, pre, 1))
    for nex in vec[cur] :
      if nex == pre : continue
      stack.append((nex, cur, 0))
  else :
    for nex in vec[cur] :
      pattern[cur] *= pattern[nex] * comb(subtree[cur] + subtree[nex], subtree[nex]) % mod
      pattern[cur] %= mod
      subtree[cur] += subtree[nex]
    subtree[cur] += 1

# BFS
queue = [(0, -1)]
while queue :
  cur, pre = queue.pop()
  for nex in vec[cur] :
    if nex == pre : continue
    pattern[nex] = pattern[cur] * subtree[nex] * inv[N - subtree[nex]] * fac[N - subtree[nex] - 1] % mod
    queue.append((nex, cur))
  
for i in range(N) :
  print((pattern[i]))
# Original solution
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()
n = int(eval(input()))
e = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = [int(i) - 1 for i in input().split()]
    e[a].append(b)
    e[b].append(a)

mod = 10**9+7

kkai = [1]
for i in range(1, 2*10 ** 5):
    kkai.append(kkai[-1] * i % mod)


def kai(x, p=mod):
    return kkai[x]


def comb(a, b, p=mod):
    if a < 0 or b < 0:
        return 0
    elif a < b:
        return 0
    if b == 0:
        return 1
    c = 1
    c *= kai(a, p)
    c *= pow(kai(b, p), p - 2, p)
    c *= pow(kai(a - b, p), p - 2, p)
    return c % p


child = [0] * n


def dfs1(i=0, r=-1):
    s = 1
    for j in e[i]:
        if j == r:
            continue
        s += dfs1(j, i)
    child[i] = s
    return s


dfs1()

a = [0] * n


def dfs2(i=0, r=-1):
    s = 1
    t = 0
    for j in e[i]:
        if j == r:
            continue
        t += child[j]
        s *= dfs2(j, i)
        s %= mod
        s *= comb(t, child[j])
        s %= mod
    a[i] = s
    return s


dfs2()

b = [0] * n


def dfs3(i=0, r=-1):
    if r == -1:
        b[i] = a[i]
    else:
        s = b[r] * comb(n-1, child[i]-1) % mod
        re = comb(n-1, child[i])
        s *= pow(re, mod - 2, mod)
        s %= mod
        b[i] = s

    for j in e[i]:
        if j == r:
            continue
        dfs3(j, i)


dfs3()

print(("\n".join(map(str, b))))


# Optimized solution
import sys
sys.setrecursionlimit(1000000)


def input():
    return sys.stdin.readline()


n = int(eval(input()))
e = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = [int(i) - 1 for i in input().split()]
    e[a].append(b)
    e[b].append(a)

mod = 10**9+7

kkai = [1]
for i in range(1, 2*10 ** 5):
    kkai.append(kkai[-1] * i % mod)


def kai(x, p=mod):
    return kkai[x]


def comb(a, b, p=mod):
    if a < 0 or b < 0:
        return 0
    elif a < b:
        return 0
    if b == 0:
        return 1
    c = 1
    c *= kai(a, p)
    c *= pow(kai(b, p), p - 2, p)
    c *= pow(kai(a - b, p), p - 2, p)
    return c % p


child = [0] * n


def dfs1(i=0, r=-1):
    s = 1
    for j in e[i]:
        if j == r:
            continue
        s += dfs1(j, i)
    child[i] = s
    return s


dfs1()
a = [0] * n


def dfs2(i=0, r=-1):
    s = kai(child[i]-1)
    t = 1
    for j in e[i]:
        if j == r:
            continue
        s *= dfs2(j, i)
        s %= mod
        t *= kai(child[j])
        t %= mod
    s *= pow(t, mod - 2, mod)
    s %= mod
    a[i] = s
    return s


dfs2()
b = [0] * n


def dfs3(i=0, r=-1):
    if r == -1:
        b[i] = a[i]
    else:
        s = b[r] * child[i] % mod
        s *= pow(n-child[i], mod - 2, mod)
        s %= mod
        b[i] = s

    for j in e[i]:
        if j == r:
            continue
        dfs3(j, i)


dfs3()
print(("\n".join(map(str, b))))
# Original solution
MOD = 10 ** 9 + 7
MAX_N = 2 * 10 ** 5

fact = [1] * (MAX_N + 1)
inverse = [1] * (MAX_N + 1)
inv_fact = [1] * (MAX_N + 1)
for i in range(2, MAX_N + 1):
  fact[i] = fact[i-1] * i % MOD
  inverse[i] = -inverse[MOD % i] * (MOD // i) % MOD
  inv_fact[i] = inv_fact[i-1] * inverse[i] % MOD

n = int(eval(input()))
edge = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = list(map(int, input().split()))
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)

for root in range(n):
  stack = [root]
  parent = [root] * n
  route = []
  while stack:
    vertex = stack.pop()
    route.append(vertex)
    for child in edge[vertex]:
      if parent[vertex] != child:
        parent[child] = vertex
        stack.append(child)

  dp = [1] * n
  size = [1] * n
  for vertex in route[:0:-1]:
    pa = parent[vertex]
    sz = size[vertex]
    dp[vertex] = dp[vertex] * fact[sz-1] % MOD
    dp[pa] = dp[pa] * dp[vertex] * inv_fact[sz] % MOD
    size[pa] += sz
  print((dp[root] * fact[size[root] - 1] % MOD))

# Optimized solution
MOD = 10 ** 9 + 7
MAX_N = 2 * 10 ** 5

fact = [1] * MAX_N
inverse = [1] * MAX_N
inv_fact = [1] * MAX_N
for i in range(2, MAX_N):
  fact[i] = fact[i-1] * i % MOD
  inverse[i] = -inverse[MOD % i] * (MOD // i) % MOD
  inv_fact[i] = inv_fact[i-1] * inverse[i] % MOD

n = int(eval(input()))
edge = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = list(map(int, input().split()))
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)

stack = [0]
parent = [0] * n
route = []
while stack:
  vertex = stack.pop()
  route.append(vertex)
  for child in edge[vertex]:
    if parent[vertex] != child:
      parent[child] = vertex
      stack.append(child)

dp = [1] * n
size = [1] * n
for vertex in route[:0:-1]:
  pa = parent[vertex]
  sz = size[vertex]
  dp[vertex] = dp[vertex] * fact[sz-1] % MOD
  dp[pa] = dp[pa] * dp[vertex] * inv_fact[sz] % MOD
  size[pa] += sz
dp[0] = dp[0] * fact[n-1] % MOD

for vertex in route[1:]:
  pa = parent[vertex]
  sz = size[vertex]
  tmp = dp[pa] * pow(dp[vertex], MOD - 2, MOD) * sz * inverse[n-sz] % MOD
  dp[vertex] = dp[vertex] * tmp % MOD

for value in dp:
  print(value)
# Original solution
MOD = 10 ** 9 + 7
MAX_N = 2 * 10 ** 5

fact = [1] * MAX_N
inverse = [1] * MAX_N
inv_fact = [1] * MAX_N
for i in range(2, MAX_N):
  fact[i] = fact[i-1] * i % MOD
  inverse[i] = -inverse[MOD % i] * (MOD // i) % MOD
  inv_fact[i] = inv_fact[i-1] * inverse[i] % MOD

n = int(eval(input()))
edge = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = list(map(int, input().split()))
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)

stack = [0]
parent = [0] * n
route = []
while stack:
  vertex = stack.pop()
  route.append(vertex)
  for child in edge[vertex]:
    if parent[vertex] != child:
      parent[child] = vertex
      stack.append(child)

dp = [1] * n
size = [1] * n
for vertex in route[:0:-1]:
  pa = parent[vertex]
  sz = size[vertex]
  dp[vertex] = dp[vertex] * fact[sz-1] % MOD
  dp[pa] = dp[pa] * dp[vertex] * inv_fact[sz] % MOD
  size[pa] += sz
dp[0] = dp[0] * fact[n-1] % MOD

for vertex in route[1:]:
  pa = parent[vertex]
  sz = size[vertex]
  tmp = dp[pa] * pow(dp[vertex], MOD - 2, MOD) * sz * inverse[n-sz] % MOD
  dp[vertex] = dp[vertex] * tmp % MOD

for value in dp:
  print(value)

# Optimized solution
# modulo
MOD = 10 ** 9 + 7

# number of vertices
n = int(eval(input()))
# adjacency list
edge = [[] for _ in range(n)]
# 0-index
for _ in range(n-1):
  a, b = list(map(int, input().split()))
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)

# factorial and inverse and inverse of factorial
fact = [1] * n
inverse = [1] * n
inv_fact = [1] * n
for i in range(2, n):
  fact[i] = fact[i-1] * i % MOD
  inverse[i] = -inverse[MOD % i] * (MOD // i) % MOD
  inv_fact[i] = inv_fact[i-1] * inverse[i] % MOD

# regarding index 0 as root of tree
# calculating parents of vertices and route from root with DFS
stack = [0]
parent = [0] * n
route = []
while stack:
  vertex = stack.pop()
  route.append(vertex)
  for child in edge[vertex]:
    if parent[vertex] != child:
      parent[child] = vertex
      stack.append(child)

# tree DP regarding index 0 as root of tree
# process from leaves to root
dp = [1] * n
size = [1] * n
for vertex in route[:0:-1]:
  pa = parent[vertex]
  sz = size[vertex]
  dp[vertex] = dp[vertex] * fact[sz-1] % MOD
  dp[pa] = dp[pa] * dp[vertex] * inv_fact[sz] % MOD
  size[pa] += sz
dp[0] = dp[0] * fact[n-1] % MOD

# rerooting
# process from root to leaves
for vertex in route[1:]:
  pa = parent[vertex]
  sz = size[vertex]
  inv_dp = pow(dp[vertex], MOD - 2, MOD)
  dp[vertex] = dp[vertex] * dp[pa] * inv_dp * sz * inverse[n-sz] % MOD

# printing result
for value in dp:
  print(value)
# Original solution
import sys
sys.setrecursionlimit(10 ** 6)


MOD = 10 ** 9 + 7


def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


def dfs(pv, v):
    global MOD
    for e in edge[v]:
        if e != pv and e not in list(V[v].keys()):
            nc, nvar = dfs(v, e)
            V[v][e] = (nc, nvar)
    childs = 0
    var = 1
    for key in [i for i in list(V[v].keys()) if i != pv]:
        cn, cvar = V[v][key]
        childs += cn
        var *= cvar
        var %= MOD
        var *= invs[cn]
        var %= MOD
    var *= modFacts[childs]
    var %= MOD
    return childs + 1, var


N = int(eval(input()))
edge = [[] for _ in range(N)]
for s in sys.stdin.readlines():
    a, b = list(map(int, s.split()))
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)

modFacts, invs = prepare(N)

V = [{} for _ in range(N)]
for i in range(N):
    dfs(-1, i)


for i in range(N):
    ans = 1
    cnt = 0
    for n, var in list(V[i].values()):
        ans *= var
        ans %= MOD
        ans *= invs[n]
        ans %= MOD
        cnt += n
    ans *= modFacts[cnt]
    print((ans % MOD))


# Optimized solution
import sys
sys.setrecursionlimit(10 ** 6)


MOD = 10 ** 9 + 7


def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


def dfs(v):
    global MOD
    childs = 0
    var = 1
    for e in edge[v]:
        if path[e] == 0:
            path[e] = 1
            nc, nvar = dfs(e)
            childs += nc
            V[v][e] = (nc, nvar)
            var *= nvar
            var %= MOD
            var *= invs[nc]
            var %= MOD
    var *= modFacts[childs]
    var %= MOD
    return childs + 1, var


def dfs2(v):
    global MOD
    tNodes = 0
    tVar = 1
    for n, var in V[v].values():
        tNodes += n
        tVar *= var
        tVar %= MOD
        tVar *= invs[n]
        tVar %= MOD
    tVar *= modFacts[tNodes]
    tVar %= MOD
    dp[v] = tVar

    for e in edge[v]:
        if dp[e] == 0:
            eNodes, eVar = V[v][e]
            nVar = (tVar * invs[tNodes] * modFacts[eNodes] * modFacts[tNodes - eNodes]) % MOD
            nVar *= pow(eVar, MOD - 2, MOD)
            nVar %= MOD
            V[e][v] = (tNodes - eNodes + 1, nVar)
            dfs2(e)


N = int(input())
edge = [[] for _ in range(N)]
for s in sys.stdin.readlines():
    a, b = map(int, s.split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)

modFacts, invs = prepare(N)

V = [{} for _ in range(N)]
path = [0] * N
dp = [0] * N
path[0] = 1
dfs(0)
dfs2(0)


print(*dp, sep='\n')
# Original solution
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]))



# Optimized solution
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]))
# Original solution
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]))



# Optimized solution
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)
# Original solution
import sys
input = sys.stdin.readline
from collections import deque

nn = 202020
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

C = lambda a, b: fa[a] * fainv[b] * fainv[a-b] % mod if 0 <= b <= a else 0

N = int(eval(input()))
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = list(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)

BU = [1] * N
TD = [1] * N
SI = [1] * N
for i in R[::-1]:
    a = 1
    s = 0
    for j in X[i]:
        a = a * BU[j] * fainv[SI[j]] % mod
        s += SI[j]
    SI[i] = s + 1
    BU[i] = fa[s] * a % mod

for i in R:
    a = TD[i] * fainv[N - SI[i]]
    for j in X[i]:
        a = a * BU[j] * fainv[SI[j]] % mod
    for j in X[i]:
        TD[j] = a * pow(BU[j], mod-2, mod) % mod * fa[SI[j]] % mod * fa[N - 1 - SI[j]] % mod

for i in range(N):
    print((BU[i] * TD[i] % mod * C(N-1, SI[i] - 1) % mod))

# Optimized solution
import sys
input = sys.stdin.readline
from collections import deque

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

C = lambda a, b: fa[a] * fainv[b] % mod * fainv[a-b] % mod if 0 <= b <= a else 0

N = int(eval(input()))
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = list(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)

BU = [1] * N
TD = [1] * N
SI = [1] * N
for i in R[::-1]:
    a = 1
    s = 0
    for j in X[i]:
        a = a * BU[j] * fainv[SI[j]] % mod
        s += SI[j]
    SI[i] = s + 1
    BU[i] = fa[s] * a % mod

for i in R:
    c = len(X[i])
    AL = [1] * (c + 1)
    AR = [1] * (c + 1)
    for j in range(c):
        AL[j+1] = AL[j] * BU[X[i][j]] % mod * fainv[SI[X[i][j]]] % mod
    for j in range(c)[::-1]:
        AR[j] = AR[j+1] * BU[X[i][j]] % mod * fainv[SI[X[i][j]]] % mod
    for j in range(c):
        TD[X[i][j]] = TD[i] * fainv[N - SI[i]] % mod * AL[j] % mod * AR[j+1] % mod * fa[N - 1 - SI[X[i][j]]] % mod

for i in range(N):
    print((BU[i] * TD[i] % mod * C(N-1, SI[i] - 1) % mod))