class Combination:

    def __init__(self, size, mod=10**9 + 7):

        self.size = size + 2

        self.mod = mod

        self.fact = [1, 1] + [0] * size

        self.factInv = [1, 1] + [0] * size

        self.inv = [0, 1] + [0] * size



        for i in range(2, self.size):

            self.fact[i] = self.fact[i - 1] * i % self.mod

            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod

            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod



    def npr(self, n, r):

        if n < r or n < 0 or r < 0:

            return 0

        return self.fact[n] * self.factInv[n - r] % self.mod



    def ncr(self, n, r):

        if n < r or n < 0 or r < 0:

            return 0

        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod



    def nhr(self, n, r):  # 重複組合せ

        return self.ncr(n + r - 1, n - 1)



    def factN(self, n):

        if n < 0:

            return 0

        return self.fact[n]



N = int(input())

MOD = 10**9 + 7

comb = Combination(N + 100)



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

for _ in range(N - 1):

    fr, to = map(int, input().split())

    edges[fr].append(to)

    edges[to].append(fr)



parent = [0] * (N + 1)

order = []

st = [1]

while st:

    now = st.pop()

    order.append(now)

    for to in edges[now]:

        if to == parent[now]:

            continue

        st.append(to)

        parent[to] = now



size = [1] * (N + 1)

for v in order[::-1]:

    size[parent[v]] += size[v]



dp = [1] * (N + 1)

for v in order[::-1]:

    dp[v] = dp[v] * comb.fact[size[v] - 1] % MOD

    dp[parent[v]] *= dp[v] * comb.factInv[size[v]]



ans = [1] * (N + 1)

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

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

eToI = [{to: i for i, to in enumerate(edges[v])} for v in range(N + 1)]



for v in order:

    pr = parent[v]

    M = len(edges[v])

    L = [1] * (M + 1)

    R = [1] * (M + 1)



    for i, to in enumerate(edges[v]):

        if to == pr:

            j = eToI[pr][v]

            L[i + 1] = L[i] * dpL[pr][j] * dpR[pr][j + 1] * comb.fact[N - size[v] - 1] * comb.factInv[N - size[v]] % MOD

        else:

            L[i + 1] = L[i] * dp[to] * comb.factInv[size[to]] % MOD

    for i, to in enumerate(edges[v][::-1]):

        if to == pr:

            j = eToI[pr][v]

            R[i + 1] = R[i] * dpL[pr][j] * dpR[pr][j + 1] * comb.fact[N - size[v] - 1] * comb.factInv[N - size[v]] % MOD

        else:

            R[i + 1] = R[i] * dp[to] * comb.factInv[size[to]] % MOD



    dpL[v] = L

    dpR[v] = R[::-1]

    ans[v] = R[-1] * comb.fact[N - 1] % MOD



print(*ans[1:], sep='\n')

class ReRooting:

    def __init__(self, size, root, identDp=0, identCum=0):

        self.size = size

        self.edges = [[] for _ in range(self.size + 1)]

        self.root = root

        self.identDp = identDp

        self.identCum = identCum



    def addEdge(self, fr, to):

        self.edges[fr].append(to)

        self.edges[to].append(fr)



    # 根を固定したときの木DP

    def lift(self, top, bottom):

        return (((top[0] * bottom[0]) % MOD * comb.ncr(top[1] + bottom[1] + 1, top[1])) % MOD, top[1] + bottom[1] + 1)



    # 子の累積

    def merge(self, cum, a):

        return (((cum[0] * a[0]) % MOD * comb.ncr(cum[1] + a[1], cum[1])) % MOD, cum[1] + a[1])



    def sol(self):

        # 普通に木DPをする

        # 並行して各頂点につき、子の値の累積liftを左右から求めておく

        # その後根から順番に、親からの寄与を求めていく(fromParent)

        N = self.size

        edges = self.edges



        st = [self.root]

        parent = [-1] * (N + 1)

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

        order = []

        while st:

            v = st.pop()

            order.append(v)

            for to in edges[v]:

                if parent[v] == to:

                    continue

                parent[to] = v

                child[v].append(to)

                st.append(to)



        dp = [self.identDp] * (N + 1)

        left = [self.identCum] * (N + 1)

        right = [self.identCum] * (N + 1)

        for v in order[::-1]:

            tmp = self.identCum

            for ch in child[v]:

                left[ch] = tmp

                tmp = self.lift(tmp, dp[ch])

            tmp = self.identCum

            for ch in reversed(child[v]):

                right[ch] = tmp

                tmp = self.lift(tmp, dp[ch])

            dp[v] = tmp



        fromParent = [self.identDp] * (N + 1)

        for v in order:

            if v == self.root:

                continue

            fromParent[v] = self.lift(self.merge(left[v], right[v]), fromParent[parent[v]])

            dp[v] = self.lift(dp[v], fromParent[v])



        return dp[:N]



class Combination:

    def __init__(self, size, MOD=10**9 + 7):

        self.size = size + 2

        self.MOD = MOD

        self.fact = [1, 1] + [0] * size

        self.factInv = [1, 1] + [0] * size

        self.inv = [0, 1] + [0] * size



        for i in range(2, self.size):

            self.fact[i] = self.fact[i - 1] * i % self.MOD

            self.inv[i] = -self.inv[self.MOD % i] * (self.MOD // i) % self.MOD

            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.MOD



    def npr(self, n, r):

        if n < r or n < 0 or r < 0:

            return 0

        return self.fact[n] * self.factInv[n - r] % self.MOD



    def ncr(self, n, r):

        if n < r or n < 0 or r < 0:

            return 0

        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.MOD) % self.MOD



    def nhr(self, n, r):  # 重複組合せ

        return self.ncr(n + r - 1, n - 1)



    def factN(self, n):

        if n < 0:

            return 0

        return self.fact[n]



N = int(input())

MOD = 10**9 + 7

comb = Combination(2 * 10**5 + 100)



tree = ReRooting(N, 0, (1, -1), (1, 0))



for _ in range(N - 1):

    fr, to = map(int, input().split())

    tree.addEdge(fr - 1, to - 1)



ans = tree.sol()

print(*[a for a, b in ans], sep='\n')

class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size
        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return (
            self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod
        )

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]


N = int(input())
MOD = 10**9 + 7
comb = Combination(N + 100)
edges = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    fr, to = map(int, input().split())
    edges[fr].append(to)
    edges[to].append(fr)
parent = [0] * (N + 1)
order = []
st = [1]
while st:
    now = st.pop()
    order.append(now)
    for to in edges[now]:
        if to == parent[now]:
            continue
        st.append(to)
        parent[to] = now
size = [1] * (N + 1)
for v in order[::-1]:
    size[parent[v]] += size[v]
dp = [1] * (N + 1)
for v in order[::-1]:
    dp[v] = dp[v] * comb.fact[size[v] - 1] % MOD
    dp[parent[v]] *= dp[v] * comb.factInv[size[v]]
ans = [1] * (N + 1)
dpL = [[] for _ in range(N + 1)]
dpR = [[] for _ in range(N + 1)]
eToI = [{to: i for i, to in enumerate(edges[v])} for v in range(N + 1)]
for v in order:
    pr = parent[v]
    M = len(edges[v])
    L = [1] * (M + 1)
    R = [1] * (M + 1)
    for i, to in enumerate(edges[v]):
        if to == pr:
            j = eToI[pr][v]
            L[i + 1] = (
                L[i]
                * dpL[pr][j]
                * dpR[pr][j + 1]
                * comb.fact[N - size[v] - 1]
                * comb.factInv[N - size[v]]
                % MOD
            )
        else:
            L[i + 1] = L[i] * dp[to] * comb.factInv[size[to]] % MOD
    for i, to in enumerate(edges[v][::-1]):
        if to == pr:
            j = eToI[pr][v]
            R[i + 1] = (
                R[i]
                * dpL[pr][j]
                * dpR[pr][j + 1]
                * comb.fact[N - size[v] - 1]
                * comb.factInv[N - size[v]]
                % MOD
            )
        else:
            R[i + 1] = R[i] * dp[to] * comb.factInv[size[to]] % MOD
    dpL[v] = L
    dpR[v] = R[::-1]
    ans[v] = R[-1] * comb.fact[N - 1] % MOD
print(*ans[1:], sep="\n")

class ReRooting:
    def __init__(self, size, root, identDp=0, identCum=0):
        self.size = size
        self.edges = [[] for _ in range(self.size + 1)]
        self.root = root
        self.identDp = identDp
        self.identCum = identCum

    def addEdge(self, fr, to):
        self.edges[fr].append(to)
        self.edges[to].append(fr)

    # 根を固定したときの木DP
    def lift(self, top, bottom):
        return (
            ((top[0] * bottom[0]) % MOD * comb.ncr(top[1] + bottom[1] + 1, top[1]))
            % MOD,
            top[1] + bottom[1] + 1,
        )

    # 子の累積
    def merge(self, cum, a):
        return (
            ((cum[0] * a[0]) % MOD * comb.ncr(cum[1] + a[1], cum[1])) % MOD,
            cum[1] + a[1],
        )

    def sol(self):
        # 普通に木DPをする
        # 並行して各頂点につき、子の値の累積liftを左右から求めておく
        # その後根から順番に、親からの寄与を求めていく(fromParent)
        N = self.size
        edges = self.edges
        st = [self.root]
        parent = [-1] * (N + 1)
        child = [[] for _ in range(N + 1)]
        order = []
        while st:
            v = st.pop()
            order.append(v)
            for to in edges[v]:
                if parent[v] == to:
                    continue
                parent[to] = v
                child[v].append(to)
                st.append(to)
        dp = [self.identDp] * (N + 1)
        left = [self.identCum] * (N + 1)
        right = [self.identCum] * (N + 1)
        for v in order[::-1]:
            tmp = self.identCum
            for ch in child[v]:
                left[ch] = tmp
                tmp = self.lift(tmp, dp[ch])
            tmp = self.identCum
            for ch in reversed(child[v]):
                right[ch] = tmp
                tmp = self.lift(tmp, dp[ch])
            dp[v] = tmp
        fromParent = [self.identDp] * (N + 1)
        for v in order:
            if v == self.root:
                continue
            fromParent[v] = self.lift(
                self.merge(left[v], right[v]), fromParent[parent[v]]
            )
            dp[v] = self.lift(dp[v], fromParent[v])
        return dp[:N]


class Combination:
    def __init__(self, size, MOD=10**9 + 7):
        self.size = size + 2
        self.MOD = MOD
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size
        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.MOD
            self.inv[i] = -self.inv[self.MOD % i] * (self.MOD // i) % self.MOD
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.MOD

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.MOD

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return (
            self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.MOD) % self.MOD
        )

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]


N = int(input())
MOD = 10**9 + 7
comb = Combination(2 * 10**5 + 100)
tree = ReRooting(N, 0, (1, -1), (1, 0))
for _ in range(N - 1):
    fr, to = map(int, input().split())
    tree.addEdge(fr - 1, to - 1)
ans = tree.sol()
print(*[a for a, b in ans], sep="\n")

+class ReRooting: +    def __init__(self, size, root, identDp=0, identCum=0): +        self.size = size +        self.edges = [[] for _ in range(self.size + 1)] +        self.root = root +        self.identDp = identDp +        self.identCum = identCum + +    def addEdge(self, fr, to): +        self.edges[fr].append(to) +        self.edges[to].append(fr) + +    # 根を固定したときの木DP +    def lift(self, top, bottom): +        return ( +            ((top[0] * bottom[0]) % MOD * comb.ncr(top[1] + bottom[1] + 1, top[1])) +            % MOD, +            top[1] + bottom[1] + 1, +        ) + +    # 子の累積 +    def merge(self, cum, a): +        return ( +            ((cum[0] * a[0]) % MOD * comb.ncr(cum[1] + a[1], cum[1])) % MOD, +            cum[1] + a[1], +        ) + +    def sol(self): +        # 普通に木DPをする +        # 並行して各頂点につき、子の値の累積liftを左右から求めておく +        # その後根から順番に、親からの寄与を求めていく(fromParent) +        N = self.size +        edges = self.edges +        st = [self.root] +        parent = [-1] * (N + 1) +        child = [[] for _ in range(N + 1)] +        order = [] +        while st: +            v = st.pop() +            order.append(v) +            for to in edges[v]: +                if parent[v] == to: +                    continue +                parent[to] = v +                child[v].append(to) +                st.append(to) +        dp = [self.identDp] * (N + 1) +        left = [self.identCum] * (N + 1) +        right = [self.identCum] * (N + 1) +        for v in order[::-1]: +            tmp = self.identCum +            for ch in child[v]: +                left[ch] = tmp +                tmp = self.lift(tmp, dp[ch]) +            tmp = self.identCum +            for ch in reversed(child[v]): +                right[ch] = tmp +                tmp = self.lift(tmp, dp[ch]) +            dp[v] = tmp +        fromParent = [self.identDp] * (N + 1) +        for v in order: +            if v == self.root: +                continue +            fromParent[v] = self.lift( +                self.merge(left[v], right[v]), fromParent[parent[v]] +            ) +            dp[v] = self.lift(dp[v], fromParent[v]) +        return dp[:N] + + -    def __init__(self, size, mod=10**9 + 7): +    def __init__(self, size, MOD=10**9 + 7): -        self.mod = mod +        self.MOD = MOD -            self.fact[i] = self.fact[i - 1] * i % self.mod -            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod -            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod +            self.fact[i] = self.fact[i - 1] * i % self.MOD +            self.inv[i] = -self.inv[self.MOD % i] * (self.MOD // i) % self.MOD +            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.MOD -        return self.fact[n] * self.factInv[n - r] % self.mod +        return self.fact[n] * self.factInv[n - r] % self.MOD -            self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod +            self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.MOD) % self.MOD -comb = Combination(N + 100) -edges = [[] for _ in range(N + 1)] +comb = Combination(2 * 10**5 + 100) +tree = ReRooting(N, 0, (1, -1), (1, 0)) -    edges[fr].append(to) -    edges[to].append(fr) -parent = [0] * (N + 1) -order = [] -st = [1] -while st: -    now = st.pop() -    order.append(now) -    for to in edges[now]: -        if to == parent[now]: -            continue -        st.append(to) -        parent[to] = now -size = [1] * (N + 1) -for v in order[::-1]: -    size[parent[v]] += size[v] -dp = [1] * (N + 1) -for v in order[::-1]: -    dp[v] = dp[v] * comb.fact[size[v] - 1] % MOD -    dp[parent[v]] *= dp[v] * comb.factInv[size[v]] -ans = [1] * (N + 1) -dpL = [[] for _ in range(N + 1)] -dpR = [[] for _ in range(N + 1)] -eToI = [{to: i for i, to in enumerate(edges[v])} for v in range(N + 1)] -for v in order: -    pr = parent[v] -    M = len(edges[v]) -    L = [1] * (M + 1) -    R = [1] * (M + 1) -    for i, to in enumerate(edges[v]): -        if to == pr: -            j = eToI[pr][v] -            L[i + 1] = ( -                L[i] -                * dpL[pr][j] -                * dpR[pr][j + 1] -                * comb.fact[N - size[v] - 1] -                * comb.factInv[N - size[v]] -                % MOD -            ) -        else: -            L[i + 1] = L[i] * dp[to] * comb.factInv[size[to]] % MOD -    for i, to in enumerate(edges[v][::-1]): -        if to == pr: -            j = eToI[pr][v] -            R[i + 1] = ( -                R[i] -                * dpL[pr][j] -                * dpR[pr][j + 1] -                * comb.fact[N - size[v] - 1] -                * comb.factInv[N - size[v]] -                % MOD -            ) -        else: -            R[i + 1] = R[i] * dp[to] * comb.factInv[size[to]] % MOD -    dpL[v] = L -    dpR[v] = R[::-1] -    ans[v] = R[-1] * comb.fact[N - 1] % MOD -print(*ans[1:], sep="\n") +    tree.addEdge(fr - 1, to - 1) +ans = tree.sol() +print(*[a for a, b in ans], sep="\n")