#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  int ch = getchar();
  int sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  x = x * sign;
}
const int maxn = 200010;
const int mod = 1000000007;
long long f[maxn], g[maxn];
vector<int> G[maxn], Pre[maxn], Suf[maxn];
int fa[maxn];
int n;
inline void DFS(int u, int F = 0) {
  fa[u] = F;
  f[u] = 1;
  Pre[u].push_back(1);
  for (int i = 0; i < (int)G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa[u]) {
      Pre[u].push_back(Pre[u].back());
      continue;
    }
    DFS(v, u);
    f[u] = f[u] * (f[v] + 1) % mod;
    Pre[u].push_back(f[u]);
  }
  Suf[u].push_back(1);
  for (int i = (int)G[u].size() - 1; i >= 0; i--) {
    int v = G[u][i];
    int Sum = Suf[u].back() * (f[v] + 1) % mod;
    if (v == fa[u]) Sum = Suf[u].back();
    Suf[u].push_back(Sum);
  }
  reverse(Suf[u].begin(), Suf[u].end());
}
inline void Solve(int u, int id = 0) {
  if (fa[u]) g[u] = 1;
  int w = fa[u];
  if (w) g[u] = (long long)Pre[w][id] * Suf[w][id + 1] % mod * (g[w] + 1) % mod;
  for (int i = 0; i < (int)G[u].size(); i++)
    if (G[u][i] != w) Solve(G[u][i], i);
}
int main() {
  read(n);
  for (int i = 2; i <= n; i++) {
    int u;
    read(u);
    G[i].push_back(u);
    G[u].push_back(i);
  }
  DFS(1);
  Solve(1);
  for (int i = 1; i <= n; i++)
    printf("%d%c", (int)(f[i] * (g[i] + 1) % mod), i == n ? '\n' : ' ');
  return 0;
}
