#include <bits/stdc++.h>
inline int getint() {
  register char ch;
  while (!isdigit(ch = getchar()))
    ;
  register int x = ch ^ '0';
  while (isdigit(ch = getchar())) x = (((x << 2) + x) << 1) + (ch ^ '0');
  return x;
}
const int N = 200001, mod = 1e9 + 7;
std::vector<int> e[N];
int f[N], par[N], sib[N];
int main() {
  const int n = getint();
  for (register int i = 2; i <= n; i++) {
    e[par[i] = getint()].push_back(i);
  }
  for (register int x = n; x; x--) {
    f[x] = 1;
    for (register std::vector<int>::iterator i = e[x].begin(); i != e[x].end();
         i++) {
      const int &y = *i;
      sib[y] = f[x];
      f[x] = (long long)f[x] * (f[y] + 1) % mod;
    }
    register int tmp = 1;
    for (register std::vector<int>::reverse_iterator i = e[x].rbegin();
         i != e[x].rend(); i++) {
      const int &y = *i;
      sib[y] = (long long)sib[y] * tmp % mod;
      tmp = (long long)tmp * (f[y] + 1) % mod;
    }
  }
  sib[1] = 1;
  for (register int i = 1; i <= n; i++) {
    const int tmp = (long long)sib[i] * f[par[i]] % mod + 1;
    printf("%d ", int((long long)f[i] * tmp % mod));
    f[i] = tmp;
  }
  return 0;
}
