#include <bits/stdc++.h>
using namespace std;
vector<long long> v[300001], pre[300001], suf[300001];
long long d[300001], ans[300001];
long long mark[300001];
long long parent[300001];
long long mod = 1000000007;
long long dfs(long long i, long long j) {
  long long s = v[i].size();
  d[i] = 1;
  parent[i] = j;
  for (long long j = 0; j < s; j++) d[i] = (d[i] * (dfs(v[i][j], i) + 1)) % mod;
  pre[i].push_back(1);
  suf[i].push_back(1);
  for (long long j = 1, k = s - 2; j < s; j++, k--) {
    pre[i].push_back((pre[i][j - 1] * (d[v[i][j - 1]] + 1)) % mod);
    suf[i].push_back((suf[i][j - 1] * (d[v[i][k + 1]] + 1)) % mod);
  }
  reverse(suf[i].begin(), suf[i].end());
  return d[i];
}
void dfs1(long long i) {
  ans[i] = d[i];
  long long s = v[i].size();
  for (long long j = 0; j < s; j++) {
    long long sti = d[i], stj = d[v[i][j]];
    d[i] = (pre[i][j] * suf[i][j]) % mod;
    if (parent[i] != 0) d[i] = (d[i] * (d[parent[i]] + 1)) % mod;
    d[v[i][j]] = (d[v[i][j]] * (d[i] + 1)) % mod;
    dfs1(v[i][j]);
    d[i] = sti, d[v[i][j]] = stj;
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  long long n, x;
  cin >> n;
  for (long long i = 2; i <= n; i++) {
    cin >> x;
    v[x].push_back(i);
  }
  dfs(1, 0);
  dfs1(1);
  for (long long i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
