#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 20;
const double eps = 1e-9;
const long long MOD = 1e9 + 7;
struct node {
  vector<int> son;
} arr[MAXN];
vector<long long> D[MAXN], P[MAXN];
long long dp[2][MAXN];
void dfs0(int rt, int fa) {
  long long res = 1;
  int son;
  for (int i = 0; i < arr[rt].son.size(); i++) {
    son = arr[rt].son[i];
    if (son == fa) {
      D[rt].push_back(1);
      P[rt].push_back(1);
      continue;
    }
    dfs0(son, rt);
    res *= dp[0][son] + 1;
    res %= MOD;
    D[rt].push_back(dp[0][son] + 1);
    P[rt].push_back(dp[0][son] + 1);
  }
  dp[0][rt] = res;
  for (int i = 1; i < D[rt].size(); i++)
    D[rt][i] = D[rt][i] * D[rt][i - 1] % MOD;
  for (int i = (int)P[rt].size() - 2; i >= 0; i--)
    P[rt][i] = P[rt][i] * P[rt][i + 1] % MOD;
}
void dfs1(int rt, int fa, long long way) {
  dp[1][rt] = way;
  int son;
  for (int i = 0; i < arr[rt].son.size(); i++) {
    son = arr[rt].son[i];
    if (son == fa) continue;
    long long tmp = way;
    if (i && i < D[rt].size()) tmp = D[rt][i - 1] * tmp % MOD;
    if (i + 1 < P[rt].size()) tmp = tmp * P[rt][i + 1] % MOD;
    dfs1(son, rt, tmp + 1);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int son;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &son);
    arr[i].son.push_back(son);
    arr[son].son.push_back(i);
  }
  dfs0(1, 0);
  dfs1(1, 1, 1);
  for (int i = 1; i <= n; i++) {
    printf("%lld ", dp[0][i] * dp[1][i] % MOD);
  }
  return 0;
}
