#include <bits/stdc++.h>
using namespace std;
const int maxn = 300000;
const int mod = 1000000007;
int dp[2][maxn];
int parent[maxn];
vector<int> G[maxn];
void addEdge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}
int _add(int a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
int _mul(int a, int b) { return (1LL * a * b) % mod; }
int BigMod(int a, int b) {
  if (!b) return 1;
  int x = BigMod(a, b >> 1);
  x = _mul(x, x);
  if (b & 1) x = _mul(x, a);
  return x;
}
int modinv(int x) { return BigMod(x, mod - 2); }
vector<int> prefix[maxn], suffix[maxn];
void dfs1(int u, int p) {
  dp[0][u] = 1;
  parent[u] = p;
  for (int v : G[u]) {
    if (v == p) {
      prefix[u].push_back(1);
      suffix[u].push_back(1);
      continue;
    }
    dfs1(v, u);
    dp[0][u] = _mul(dp[0][u], _add(dp[0][v], 1));
    prefix[u].push_back(_add(dp[0][v], 1));
    suffix[u].push_back(_add(dp[0][v], 1));
  }
}
int getIndex(int p, int c) {
  return (int)(lower_bound(G[p].begin(), G[p].end(), c) - G[p].begin());
}
void dfs2(int u, int p) {
  dp[1][u] = 1;
  if (p) {
    int id = getIndex(p, u);
    int val = _mul(prefix[p][id], suffix[p][id]);
    val = _mul(val, dp[1][p]);
    dp[1][u] = _add(1, val);
  }
  for (int v : G[u]) {
    if (v == p) continue;
    dfs2(v, u);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int p;
    scanf("%d", &p);
    addEdge(p, i);
  }
  for (int i = 1; i <= n; i++) sort(G[i].begin(), G[i].end());
  dfs1(1, 0);
  for (int i = 1; i <= n; i++) {
    int val = 1;
    int sz = (int)prefix[i].size();
    for (int j = 0; j < sz; j++) {
      int temp = prefix[i][j];
      prefix[i][j] = val;
      val = _mul(val, temp);
    }
    val = 1;
    for (int j = sz - 1; j >= 0; j--) {
      int temp = suffix[i][j];
      suffix[i][j] = val;
      val = _mul(val, temp);
    }
  }
  dfs2(1, 0);
  for (int i = 1; i <= n; i++) {
    int ans = _mul(dp[0][i], dp[1][i]);
    printf("%d ", ans);
  }
  return 0;
}
