#include <bits/stdc++.h>
struct edge {
  int to, nxt;
} e[1000000];
int n, cnt, t, fi[200005], a[200005], b[200005], c[200005];
long long f[200005], g[200005];
void add(int u, int v) {
  e[++cnt].to = v;
  e[cnt].nxt = fi[u];
  fi[u] = cnt;
}
void dp(int x) {
  f[x] = 1;
  a[++t] = x;
  for (int i = fi[x]; i; b[e[i].to] = e[e[i].nxt].to, i = e[i].nxt) {
    dp(e[i].to);
    (f[x] *= (f[e[i].to] + 1)) %= 1000000007;
  }
}
void move(int x, long long y) {
  g[x] = (++y) * f[x] % 1000000007;
  for (int i = fi[x]; i; i = e[i].nxt) {
    move(e[i].to, 1ll * y * c[b[e[i].to]] % 1000000007);
    y = y * (f[e[i].to] + 1) % 1000000007;
  }
}
int main() {
  scanf("%d\n", &n);
  for (int i = 2; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    add(x, i);
  }
  dp(1);
  c[0] = 1;
  for (int i = n; i; --i)
    c[a[i]] = 1ll * (f[a[i]] + 1) * c[b[a[i]]] % 1000000007;
  move(1, 0);
  for (int i = 1; i <= n; ++i) printf("%d ", g[i]);
  return 0;
}
