#include <bits/stdc++.h>
using namespace std;
long long n;
const long long maxn = 2e5 + 100;
const long long mod = 1e9 + 7;
vector<long long> G[maxn];
long long dp[maxn];
long long oth[maxn];
long long fs[maxn], ts[maxn];
long long ans[maxn];
void myinit() {
  cin >> n;
  for (long long i = 2; i <= n; i++) {
    long long u;
    cin >> u;
    G[u].push_back(i);
  }
  memset(dp, 0, sizeof(dp));
  memset(oth, 0, sizeof(oth));
}
void dfs1(long long x) {
  long long s = 1;
  for (long long i = 0; i < G[x].size(); i++) {
    long long tmp = G[x][i];
    dfs1(tmp);
    s = s * (dp[tmp] + 1);
    s %= mod;
  }
  dp[x] = s;
}
void dfs2(long long x) {
  fs[0] = 1;
  for (long long i = 0; i < G[x].size(); i++) {
    long long tmp = G[x][i];
    fs[i + 1] = fs[i] * (dp[tmp] + 1);
    fs[i + 1] %= mod;
  }
  ts[G[x].size() + 1] = 1;
  for (long long i = (long long)G[x].size() - 1; i >= 0; i--) {
    long long tmp = G[x][i];
    ts[i + 1] = (ts[i + 2] * (dp[tmp] + 1)) % mod;
  }
  for (long long i = 0; i < G[x].size(); i++) {
    oth[G[x][i]] = ((fs[i] * ts[i + 2] % mod) * oth[x] + 1) % mod;
  }
  for (long long i = 0; i < G[x].size(); i++) {
    dfs2(G[x][i]);
  }
}
void dfs3(long long x) {
  for (long long i = 0; i < G[x].size(); i++) {
    long long tmp = G[x][i];
    ans[tmp] = (oth[tmp] * dp[tmp]) % mod;
    dfs3(tmp);
  }
}
void solve() {
  myinit();
  dfs1(1);
  oth[1] = 1;
  dfs2(1);
  ans[1] = dp[1];
  dfs3(1);
  for (long long i = 1; i <= n; i++) {
    cout << ans[i] << ' ';
  }
}
int main() {
  solve();
  return 0;
}
