import sys,heapq



def cmb(n, r, mod):#コンビネーションの高速計算　

    if ( r<0 or r>n ):

        return 0

    r = min(r, n-r)

    return g1[n] * g2[r] * g2[n-r] % mod



mod = 10**9+7 #出力の制限

N = 2*10**5

g1 = [1, 1] # 元テーブル

g2 = [1, 1] #逆元テーブル

inverse = [0, 1] #逆元テーブル計算用テーブル



for i in range( 2, N + 1 ):

    g1.append( ( g1[-1] * i ) % mod )

    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )

    g2.append( (g2[-1] * inverse[-1]) % mod )





input=sys.stdin.readline



N=int(eval(input()))

hen={i:[] for i in range(1,N+1)}

for i in range(0,N-1):

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

    hen[a].append(b)

    hen[b].append(a)



parent={i:-1 for i in range(1,N+1)}

parent[1]=0

q=[]

q.append(1)

heapq.heapify(q)

sub=[]

heapq.heapify(sub)

while q!=[]:

    while q!=[]:

        x=heapq.heappop(q)

        for p in hen[x]:

            if parent[p]==-1:

                parent[p]=x

                heapq.heappush(sub,p)

        #何らかの操作

        #ここでsubキューに次に使うものを格納

        if q==[]:

            q=sub

            sub=[]

            heapq.heapify(sub)

            break



ans={i:1 for i in range(1,N+1)}

subtreesize={i:1 for i in range(1,N+1)}

flag={i:0 for i in range(0,N+1)}

q=[]

for i in range(1,N+1):

    if i!=1 and len(hen[i])==1:

        q.append(i)



heapq.heapify(q)

sub=[]

heapq.heapify(sub)

while q!=[]:

    while q!=[]:

        x=heapq.heappop(q)

        p=parent[x]

        if p!=1:

            ans[p]=(ans[p]*ans[x]*g2[subtreesize[x]])%mod

            subtreesize[p]+=subtreesize[x]

            flag[p]+=1

            if flag[p]==len(hen[p])-1:

                ans[p]=(ans[p]*g1[subtreesize[p]-1])%mod

                heapq.heappush(sub,p)

        else:

            subtreesize[1]+=subtreesize[x]

            ans[1]=(ans[1]*ans[x]*g2[subtreesize[x]])%mod

            flag[1]+=1

            if flag[1]==len(hen[1]):

                ans[1]=(ans[1]*g1[subtreesize[1]-1])%mod

        #何らかの操作

        #ここでsubキューに次に使うものを格納

        if q==[]:

            q=sub

            sub=[]

            heapq.heapify(sub)

            break



q=[1]

flag2={i:0 for i in range(1,N+1)}

flag2[1]=1

heapq.heapify(q)

sub=[]

heapq.heapify(sub)

while q!=[]:

    while q!=[]:

        x=heapq.heappop(q)

        for p in hen[x]:

            if flag2[p]==0:

                if len(hen[p])!=1:

                    ans[p]=(ans[x]*pow(N-subtreesize[p],mod-2,mod)*g1[subtreesize[p]]*g2[subtreesize[p]-1])%mod

                    flag2[p]=1

                    heapq.heappush(sub,p)

                else:

                    ans[p]=(ans[x]*pow(N-1,mod-2,mod))%mod



        #何らかの操作

        #ここでsubキューに次に使うものを格納

        if q==[]:

            q=sub

            sub=[]

            heapq.heapify(sub)

            break



for i in range(1,N+1):

    print((ans[i]))
import sys



def cmb(n, r, mod):#コンビネーションの高速計算　

    if ( r<0 or r>n ):

        return 0

    r = min(r, n-r)

    return g1[n] * g2[r] * g2[n-r] % mod



mod = 10**9+7 #出力の制限

N = 2*10**5

g1 = [1, 1] # 元テーブル

g2 = [1, 1] #逆元テーブル

inverse = [0, 1] #逆元テーブル計算用テーブル



for i in range( 2, N + 1 ):

    g1.append( ( g1[-1] * i ) % mod )

    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )

    g2.append( (g2[-1] * inverse[-1]) % mod )





input=sys.stdin.readline

write=sys.stdout.write



N=int(eval(input()))

hen={i:[] for i in range(1,N+1)}

for i in range(0,N-1):

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

    hen[a].append(b)

    hen[b].append(a)



parent={i:-1 for i in range(1,N+1)}

parent[1]=0

q=[]

q.append(1)

sub=[]

while q!=[]:

    while q!=[]:

        x=q.pop()

        for p in hen[x]:

            if parent[p]==-1:

                parent[p]=x

                sub.append(p)

        #何らかの操作

        #ここでsubキューに次に使うものを格納

        if q==[]:

            q=sub

            sub=[]

            break



ans={i:1 for i in range(1,N+1)}

subtreesize={i:1 for i in range(1,N+1)}

flag={i:0 for i in range(0,N+1)}

q=[]

for i in range(1,N+1):

    if i!=1 and len(hen[i])==1:

        q.append(i)





sub=[]

while q!=[]:

    while q!=[]:

        x=q.pop()

        p=parent[x]

        if p!=1:

            ans[p]=(ans[p]*ans[x]*g2[subtreesize[x]])%mod

            subtreesize[p]+=subtreesize[x]

            flag[p]+=1

            if flag[p]==len(hen[p])-1:

                ans[p]=(ans[p]*g1[subtreesize[p]-1])%mod

                sub.append(p)

        else:

            subtreesize[1]+=subtreesize[x]

            ans[1]=(ans[1]*ans[x]*g2[subtreesize[x]])%mod

            flag[1]+=1

            if flag[1]==len(hen[1]):

                ans[1]=(ans[1]*g1[subtreesize[1]-1])%mod

        #何らかの操作

        #ここでsubキューに次に使うものを格納

        if q==[]:

            q=sub

            sub=[]

            break



q=[1]

flag2={i:0 for i in range(1,N+1)}

flag2[1]=1

sub=[]

while q!=[]:

    while q!=[]:

        x=q.pop()

        for p in hen[x]:

            if flag2[p]==0:

                if len(hen[p])!=1:

                    ans[p]=(ans[x]*pow(N-subtreesize[p],mod-2,mod)*g1[subtreesize[p]]*g2[subtreesize[p]-1])%mod

                    flag2[p]=1

                    sub.append(p)

                else:

                    ans[p]=(ans[x]*pow(N-1,mod-2,mod))%mod



        #何らかの操作

        #ここでsubキューに次に使うものを格納

        if q==[]:

            q=sub

            sub=[]

            break



for i in range(1,N+1):

    write(str(ans[i])+"\n")
import sys, heapq


def cmb(n, r, mod):  # コンビネーションの高速計算
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10**9 + 7  # 出力の制限
N = 2 * 10**5
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル
for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)
input = sys.stdin.readline
N = int(eval(input()))
hen = {i: [] for i in range(1, N + 1)}
for i in range(0, N - 1):
    a, b = list(map(int, input().split()))
    hen[a].append(b)
    hen[b].append(a)
parent = {i: -1 for i in range(1, N + 1)}
parent[1] = 0
q = []
q.append(1)
heapq.heapify(q)
sub = []
heapq.heapify(sub)
while q != []:
    while q != []:
        x = heapq.heappop(q)
        for p in hen[x]:
            if parent[p] == -1:
                parent[p] = x
                heapq.heappush(sub, p)
        # 何らかの操作
        # ここでsubキューに次に使うものを格納
        if q == []:
            q = sub
            sub = []
            heapq.heapify(sub)
            break
ans = {i: 1 for i in range(1, N + 1)}
subtreesize = {i: 1 for i in range(1, N + 1)}
flag = {i: 0 for i in range(0, N + 1)}
q = []
for i in range(1, N + 1):
    if i != 1 and len(hen[i]) == 1:
        q.append(i)
heapq.heapify(q)
sub = []
heapq.heapify(sub)
while q != []:
    while q != []:
        x = heapq.heappop(q)
        p = parent[x]
        if p != 1:
            ans[p] = (ans[p] * ans[x] * g2[subtreesize[x]]) % mod
            subtreesize[p] += subtreesize[x]
            flag[p] += 1
            if flag[p] == len(hen[p]) - 1:
                ans[p] = (ans[p] * g1[subtreesize[p] - 1]) % mod
                heapq.heappush(sub, p)
        else:
            subtreesize[1] += subtreesize[x]
            ans[1] = (ans[1] * ans[x] * g2[subtreesize[x]]) % mod
            flag[1] += 1
            if flag[1] == len(hen[1]):
                ans[1] = (ans[1] * g1[subtreesize[1] - 1]) % mod
        # 何らかの操作
        # ここでsubキューに次に使うものを格納
        if q == []:
            q = sub
            sub = []
            heapq.heapify(sub)
            break
q = [1]
flag2 = {i: 0 for i in range(1, N + 1)}
flag2[1] = 1
heapq.heapify(q)
sub = []
heapq.heapify(sub)
while q != []:
    while q != []:
        x = heapq.heappop(q)
        for p in hen[x]:
            if flag2[p] == 0:
                if len(hen[p]) != 1:
                    ans[p] = (
                        ans[x]
                        * pow(N - subtreesize[p], mod - 2, mod)
                        * g1[subtreesize[p]]
                        * g2[subtreesize[p] - 1]
                    ) % mod
                    flag2[p] = 1
                    heapq.heappush(sub, p)
                else:
                    ans[p] = (ans[x] * pow(N - 1, mod - 2, mod)) % mod
        # 何らかの操作
        # ここでsubキューに次に使うものを格納
        if q == []:
            q = sub
            sub = []
            heapq.heapify(sub)
            break
for i in range(1, N + 1):
    print((ans[i]))

import sys


def cmb(n, r, mod):  # コンビネーションの高速計算
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10**9 + 7  # 出力の制限
N = 2 * 10**5
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル
for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)
input = sys.stdin.readline
write = sys.stdout.write
N = int(eval(input()))
hen = {i: [] for i in range(1, N + 1)}
for i in range(0, N - 1):
    a, b = list(map(int, input().split()))
    hen[a].append(b)
    hen[b].append(a)
parent = {i: -1 for i in range(1, N + 1)}
parent[1] = 0
q = []
q.append(1)
sub = []
while q != []:
    while q != []:
        x = q.pop()
        for p in hen[x]:
            if parent[p] == -1:
                parent[p] = x
                sub.append(p)
        # 何らかの操作
        # ここでsubキューに次に使うものを格納
        if q == []:
            q = sub
            sub = []
            break
ans = {i: 1 for i in range(1, N + 1)}
subtreesize = {i: 1 for i in range(1, N + 1)}
flag = {i: 0 for i in range(0, N + 1)}
q = []
for i in range(1, N + 1):
    if i != 1 and len(hen[i]) == 1:
        q.append(i)
sub = []
while q != []:
    while q != []:
        x = q.pop()
        p = parent[x]
        if p != 1:
            ans[p] = (ans[p] * ans[x] * g2[subtreesize[x]]) % mod
            subtreesize[p] += subtreesize[x]
            flag[p] += 1
            if flag[p] == len(hen[p]) - 1:
                ans[p] = (ans[p] * g1[subtreesize[p] - 1]) % mod
                sub.append(p)
        else:
            subtreesize[1] += subtreesize[x]
            ans[1] = (ans[1] * ans[x] * g2[subtreesize[x]]) % mod
            flag[1] += 1
            if flag[1] == len(hen[1]):
                ans[1] = (ans[1] * g1[subtreesize[1] - 1]) % mod
        # 何らかの操作
        # ここでsubキューに次に使うものを格納
        if q == []:
            q = sub
            sub = []
            break
q = [1]
flag2 = {i: 0 for i in range(1, N + 1)}
flag2[1] = 1
sub = []
while q != []:
    while q != []:
        x = q.pop()
        for p in hen[x]:
            if flag2[p] == 0:
                if len(hen[p]) != 1:
                    ans[p] = (
                        ans[x]
                        * pow(N - subtreesize[p], mod - 2, mod)
                        * g1[subtreesize[p]]
                        * g2[subtreesize[p] - 1]
                    ) % mod
                    flag2[p] = 1
                    sub.append(p)
                else:
                    ans[p] = (ans[x] * pow(N - 1, mod - 2, mod)) % mod
        # 何らかの操作
        # ここでsubキューに次に使うものを格納
        if q == []:
            q = sub
            sub = []
            break
for i in range(1, N + 1):
    write(str(ans[i]) + "\n")

-import sys, heapq +import sys +write = sys.stdout.write -heapq.heapify(q) -heapq.heapify(sub) -        x = heapq.heappop(q) +        x = q.pop() -                heapq.heappush(sub, p) +                sub.append(p) -            heapq.heapify(sub) -heapq.heapify(q) -heapq.heapify(sub) -        x = heapq.heappop(q) +        x = q.pop() -                heapq.heappush(sub, p) +                sub.append(p) -            heapq.heapify(sub) -heapq.heapify(q) -heapq.heapify(sub) -        x = heapq.heappop(q) +        x = q.pop() -                    heapq.heappush(sub, p) +                    sub.append(p) -            heapq.heapify(sub) -    print((ans[i])) +    write(str(ans[i]) + "\n")