#include <bits/stdc++.h>
using namespace std;
const int mod = (1e9) + 7;
vector<int> adj[200010];
int sub[200010];
int out[200010];
int val[200010];
int inv(int a, int b) {
  a %= b;
  if (a == 1) return a;
  int x = (-inv(b, a) * 1LL * b + 1) / a;
  return x < 0 ? x + b : x;
}
void dfs(int v, int p) {
  int i, u;
  int pr = 1;
  sub[v] = 1;
  for (i = 0; i < adj[v].size(); ++i) {
    u = adj[v][i];
    if (u == p) continue;
    dfs(u, v);
    val[u] = pr;
    pr = (1LL * pr * (1 + sub[u])) % mod;
    sub[v] = (1LL * sub[v] * (1 + sub[u])) % mod;
  }
  pr = 1;
  for (--i; i >= 0; --i) {
    u = adj[v][i];
    if (u == p) continue;
    val[u] = (1LL * val[u] * pr) % mod;
    pr = (1LL * pr * (1 + sub[u])) % mod;
  }
}
void dfs2(int v, int p) {
  int i, u;
  if (p >= 0) {
    out[v] = (1LL * val[v] * out[p]) % mod;
  }
  out[v] += 1;
  out[v] %= mod;
  for (i = 0; i < adj[v].size(); ++i) {
    u = adj[v][i];
    if (u == p) continue;
    dfs2(u, v);
  }
}
int N;
int main() {
  int i, x;
  ios::sync_with_stdio(0);
  cin >> N;
  for (i = 1; i < N; ++i) {
    cin >> x;
    --x;
    adj[x].push_back(i);
    adj[i].push_back(x);
  }
  dfs(0, -1);
  dfs2(0, -1);
  for (i = 0; i < N; ++i) {
    cout << (1LL * out[i] * sub[i]) % mod << " ";
  }
  return 0;
}
