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 (109 + 7).

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 2·105) — the number of cities in the country. Next line contains n - 1 positive integers p2, p3, p4, ..., pn (1 ≤ pi ≤ i - 1) — the description of the roads in the country. Number pi means that the country has a road connecting city pi and city i. 

Output

Print n integers a1, a2, ..., an, where ai is the sought number of ways to improve the quality of the roads modulo 1 000 000 007 (109 + 7), if the capital of the country is at city number i.

Examples

Input

3
1 1


Output

4 3 3

Input

5
1 2 3 4


Output

5 8 9 8 5
#include <bits/stdc++.h>
using namespace std;
const double error = 1e-15;
const double pi = 2 * acos(0);
const int maxn = (int)1e5 + 10;
const int mod = (int)1e9 + 7;
int dx[] = {0, -1, 0, +1, -1, -1, +1, +1};
int dy[] = {-1, 0, +1, 0, -1, +1, +1, -1};
long dp[200005], pv[200005];
vector<long> L[200005], R[200005], g[200005];
int p[200005];
long dfs(int v) {
  long j, u, x;
  dp[v] = 1;
  for (j = 0; j < g[v].size(); j++) {
    u = g[v][j];
    x = dfs(u);
    dp[v] = (1LL * dp[v] * (x + 1)) % mod;
    L[v].push_back(dp[v]);
  }
  R[v].resize(g[v].size());
  for (j = g[v].size() - 1; j >= 0; j--) {
    u = g[v][j];
    x = j == g[v].size() - 1 ? (dp[u] + 1) : (1LL * (dp[u] + 1) * x) % mod;
    R[v][j] = x;
  }
  return dp[v];
}
int main() {
  ios_base::sync_with_stdio(0);
  long n, i, x, pp, j, y;
  cin >> n;
  for (i = 2; i <= n; i++) {
    cin >> p[i];
    g[p[i]].push_back(i);
  }
  x = dfs(1);
  cout << x << " ";
  pv[1] = 1;
  for (i = 2; i <= n; i++) {
    pp = p[i];
    x = pv[pp];
    y = lower_bound(g[pp].begin(), g[pp].end(), i) - g[pp].begin();
    if (y > 0) {
      x = (1LL * x * L[pp][y - 1]) % mod;
    }
    if (y < g[pp].size() - 1) {
      x = (1LL * x * R[pp][y + 1]) % mod;
    }
    pv[i] = x + 1;
    x = (1LL * (x + 1) * dp[i]) % mod;
    cout << x << " ";
  }
  return 0;
}
