#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int MAXN = 200005;
int dp[MAXN];
int up[MAXN];
int head[MAXN];
int edge[MAXN << 1];
int next1[MAXN << 1];
int stk[MAXN];
int sz;
int esz;
int add(int x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
  return x;
}
void addedge(int u, int v) {
  edge[esz] = v;
  next1[esz] = head[u];
  head[u] = esz++;
}
void dfs(int u, int p) {
  int res = 1;
  for (int i = head[u]; i + 1; i = next1[i]) {
    int v = edge[i];
    if (v == p) continue;
    dfs(v, u);
    res = (long long)res * add(dp[v], 1) % MOD;
  }
  dp[u] = res;
}
void dfs2(int u, int p) {
  dp[u] = (long long)dp[u] * up[u] % MOD;
  int res = 1;
  sz = 0;
  for (int i = head[u]; i + 1; i = next1[i]) {
    int v = edge[i];
    if (v == p) continue;
    stk[sz++] = v;
    up[v] = (long long)up[v] * res % MOD;
    res = (long long)res * add(dp[v], 1) % MOD;
  }
  res = 1;
  for (int i = sz - 1; i >= 0; i--) {
    int v = stk[i];
    up[v] = (long long)up[v] * res % MOD * up[u] % MOD;
    up[v] = add(up[v], 1);
    res = (long long)res * add(dp[v], 1) % MOD;
  }
  for (int i = head[u]; i + 1; i = next1[i]) {
    int v = edge[i];
    if (v == p) continue;
    dfs2(v, u);
  }
}
int main() {
  int n;
  memset(head, -1, sizeof(head));
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int p;
    scanf("%d", &p);
    addedge(p, i);
    addedge(i, p);
  }
  for (int i = 1; i <= n; i++) up[i] = 1;
  dfs(1, 0);
  dfs2(1, 0);
  for (int i = 1; i <= n; i++) printf("%d ", dp[i]);
  puts("");
  return 0;
}
