#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int N = (int)2e5 + 10, M = (int)1e9 + 7;
int n, dp1[N], dp2[N], dp[N], dep[N], siz[N], s[N], e[N], t[N], rnk[N], ti,
    prod[N << 2];
vector<int> ed[N], ord[N];
void build(int id, int l, int r) {
  if (l == r) {
    prod[id] = (1 + dp1[rnk[l]]) % M;
    return;
  }
  int mi = (l + r) >> 1;
  build(id << 1, l, mi);
  build(id << 1 | 1, mi + 1, r);
  prod[id] = (LL)prod[id << 1] * prod[id << 1 | 1] % M;
}
int query(int id, int l, int r, int x, int y) {
  if (x > r || y < l) return 1;
  if (x <= l && r <= y) return prod[id];
  int mi = (l + r) >> 1;
  return (LL)query(id << 1, l, mi, x, y) * query(id << 1 | 1, mi + 1, r, x, y) %
         M;
}
void dfs1(int u) {
  ord[dep[u]].push_back(u);
  siz[u] = 1;
  dp1[u] = 1;
  for (int v : ed[u]) {
    dep[v] = dep[u] + 1;
    dfs1(v);
    siz[u] += siz[v];
    dp1[u] = (LL)dp1[u] * ((1 + dp1[v]) % M) % M;
  }
}
void dfs2(int u) {
  dp[u] = (LL)dp1[u] * dp2[u] % M;
  for (int v : ed[u]) {
    LL val =
        (LL)query(1, 1, n, s[u], t[v] - 1) * query(1, 1, n, t[v] + 1, e[u]) % M;
    dp2[v] = (1 + (LL)dp2[u] * val % M) % M;
    dfs2(v);
  }
}
void construct() {
  for (int i = 0; i < n; i++) {
    for (int u : ord[i]) {
      ++ti;
      rnk[ti] = u;
      t[u] = ti;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!ed[i].empty()) {
      s[i] = t[ed[i][0]];
      e[i] = t[ed[i].back()];
    }
  }
}
int main() {
  scanf("%d", &n);
  int u, v;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &u);
    ed[u].push_back(i);
  }
  dep[1] = 0;
  dfs1(1);
  construct();
  build(1, 1, n);
  dp2[1] = 1;
  dfs2(1);
  for (int i = 1; i <= n; i++) printf("%d ", dp[i]);
  puts("");
}
