#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void ckmin(T &a, U b) {
  if (a > b) a = b;
}
template <class T, class U>
void ckmax(T &a, U b) {
  if (a < b) a = b;
}
const int MAXN = 200013;
const int INF = 1000000007;
int add(int a, int b) {
  a += b;
  if (a >= INF) a -= INF;
  return a;
}
int mul(int a, int b) { return (long long)a * b % INF; }
int sub(int a, int b) {
  a -= b;
  if (a < 0) a += INF;
  return a;
}
int pwr(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) res = mul(res, a);
    b >>= 1;
    a = mul(a, a);
  }
  return res;
}
int inv(int a) { return pwr(a, INF - 2); }
int dvd(int a, int b) { return mul(a, inv(b)); }
int N;
vector<int> edge[MAXN];
int dp[MAXN];
int ans[MAXN];
void dfs(int u, int p) {
  if (u) {
    edge[u].erase(find((edge[u]).begin(), (edge[u]).end(), p));
  }
  for (int v : edge[u]) {
    dfs(v, u);
  }
  dp[u] = 1;
  for (int v : edge[u]) {
    dp[u] = mul(dp[u], dp[v]);
  }
  dp[u] = add(dp[u], 1);
}
void solve(int u, int prod) {
  vector<int> pref(((int)(edge[u]).size()) + 1),
      suf(((int)(edge[u]).size()) + 1);
  pref[0] = 1;
  for (auto i = (0); i < (((int)(edge[u]).size())); i++) {
    int v = edge[u][i];
    pref[i + 1] = mul(pref[i], dp[v]);
  }
  suf[((int)(edge[u]).size())] = 1;
  for (auto i = (((int)(edge[u]).size())) - 1; i >= (0); i--) {
    int v = edge[u][i];
    suf[i] = mul(suf[i + 1], dp[v]);
  }
  for (auto i = (0); i < (((int)(edge[u]).size())); i++) {
    int v = edge[u][i];
    int ways = add(1, mul(prod, mul(pref[i], suf[i + 1])));
    ans[v] = mul(ans[v], ways);
    solve(v, ways);
  }
}
int32_t main() {
  cout << fixed << setprecision(12);
  cerr << fixed << setprecision(4);
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (auto i = (1); i < (N); i++) {
    int p;
    cin >> p;
    p--;
    edge[i].push_back(p);
    edge[p].push_back(i);
  }
  dfs(0, N);
  for (auto i = (0); i < (N); i++) {
    ans[i] = sub(dp[i], 1);
  }
  solve(0, 1);
  for (auto i = (0); i < (N); i++) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
  return 0;
}
