The country has *n* cities and *n* - 1 bidirectional roads, it is possible to get from every city to any other one if you move only along the roads. The cities are numbered with integers from 1 to *n* inclusive.

All the roads are initially bad, but the government wants to improve the state of some roads. We will assume that the citizens are happy about road improvement if the path from the capital located in city *x* to any other city contains at most one bad road.

Your task is — for every possible *x* determine the number of ways of improving the quality of some roads in order to meet the citizens' condition. As those values can be rather large, you need to print each value modulo 1 000 000 007 (10<sup class="upper-index">9</sup> + 7).
The first line of the input contains a single integer *n* (2 ≤ *n* ≤ 2·10<sup class="upper-index">5</sup>) — the number of cities in the country. Next line contains *n* - 1 positive integers *p*<sub class="lower-index">2</sub>, *p*<sub class="lower-index">3</sub>, *p*<sub class="lower-index">4</sub>, ..., *p*<sub class="lower-index">*n*</sub> (1 ≤ *p*<sub class="lower-index">*i*</sub> ≤ *i* - 1) — the description of the roads in the country. Number *p*<sub class="lower-index">*i*</sub> means that the country has a road connecting city *p*<sub class="lower-index">*i*</sub> and city *i*.

n = int(input())
p = list(map(int, input().split()))
mod = 10 ** 9 + 7
g = [[] for _ in range(n)]
for i in range(n - 1):
    g[p[i] - 1].append(i + 1)
    g[i + 1].append(p[i] - 1)

count = [[0, 1] for _ in range(n)]
from types import GeneratorType


def bootstrap(f, stack=[]):
    def wrappedfunc(*args, **kwargs):
        if stack:
            return f(*args, **kwargs)
        else:
            to = f(*args, **kwargs)
            while True:
                if type(to) is GeneratorType:
                    stack.append(to)
                    to = next(to)
                else:
                    stack.pop()
                    if not stack:
                        break
                    to = stack[-1].send(to)
            return to

    return wrappedfunc


def mul(x, y):
    e1, x1 = x
    e2, x2 = y
    if e2 > 0:
        return [e1, x1]
    elif x2 + 1 == mod:
        return [e1 + 1, x1]
    else:
        return [e1, x1 * (x2 + 1) % mod]


def div(x, y):
    e1, x1 = x
    e2, x2 = y
    if e2 > 0:
        return [e1, x1]
    elif x2 + 1 == mod:
        return [e1 - 1, x1]
    else:
        return [e1, x1 * pow(x2 + 1, mod - 2, mod) % mod]


@bootstrap
def dfs1(son, fa):
    for x in g[son]:
        if x != fa:
            yield dfs1(x, son)
            count[son] = mul(count[son], count[x])
    yield


dfs1(0, -1)

ans = [[0, 1] for _ in range(n)]


@bootstrap
def dfs2(son, fa, from_fa):
    ans[son] = mul(count[son], from_fa)
    for x in g[son]:
        if x != fa:
            yield dfs2(x, son, div(ans[son], count[x]))
    yield


dfs2(0, -1, [0, 0])
print(*[x[1] if x[0] == 0 else 0 for x in ans])