#include <bits/stdc++.h>
int next[1 + 200000 - 1], jj[1 + 200000 - 1];
int link(int l, int j) {
  static int _ = 1;
  next[_] = l;
  jj[_] = j;
  return _++;
}
int ao[200000], dp[200000], dq[200000];
void dfs1(int i) {
  int l;
  long long x;
  x = 1;
  for (l = ao[i]; l; l = next[l]) {
    int j = jj[l];
    dfs1(j);
    x = x * (dp[j] + 1) % 1000000007;
  }
  dp[i] = x;
}
void dfs2(int i) {
  static int pp[200000], qq[200000];
  int l, h;
  long long p, q;
  p = q = 1;
  h = 0;
  for (l = ao[i]; l; l = next[l]) {
    int j = jj[l];
    pp[h] = p;
    qq[h] = j;
    p = p * (dp[j] + 1) % 1000000007;
    h++;
  }
  while (h--) {
    int j = qq[h];
    dq[j] = (pp[h] * q % 1000000007 * dq[i] + 1) % 1000000007;
    q = q * (dp[j] + 1) % 1000000007;
  }
  for (l = ao[i]; l; l = next[l]) {
    int j = jj[l];
    dfs2(j);
  }
}
int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    int p;
    scanf("%d", &p), p--;
    ao[p] = link(ao[p], i);
  }
  dfs1(0);
  dq[0] = 1;
  dfs2(0);
  for (i = 0; i < n; i++)
    printf("%lld ", (long long)dp[i] * dq[i] % 1000000007);
  printf("\n");
  return 0;
}
