#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, x, ans[N], mod = 1e9 + 7, dp[N], t, zero[N], wzero[N];
vector<int> v[N];
void add(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}
void mul(int &x, int y) { x = (1LL * x * y) % mod; }
int bpow(int x, int y) {
  int ret = 1, temp = x;
  while (y) {
    if (y & 1) mul(ret, temp);
    y /= 2;
    mul(temp, temp);
  }
  return ret;
}
int dfs(int x, int y) {
  int &ret = dp[x];
  if (ret != -1) return ret;
  ret = 1;
  for (int i = 0; i < v[x].size(); ++i)
    if (v[x][i] != y) mul(ret, dfs(v[x][i], x));
  if (y != 0) add(ret, 1);
  return ret;
}
void calc(int x, int y, int bef) {
  int nv;
  wzero[x] = 1;
  if (x != 1) {
    if (dp[x] == 0 && zero[y] == 1)
      bef = wzero[y];
    else
      mul(bef, bpow(dp[x], mod - 2));
    add(bef, 1);
    nv = bef;
    add(dp[x], mod - 1);
    mul(nv, dp[x]);
  } else
    nv = ans[1];
  if (x != 1 && bef == 0)
    ++zero[x];
  else if (x != 1)
    mul(wzero[x], bef);
  for (int i = 0; i < v[x].size(); ++i)
    if (v[x][i] != y)
      if (dp[v[x][i]] == 0)
        ++zero[x];
      else
        mul(wzero[x], dp[v[x][i]]);
  ans[x] = nv;
  for (int i = 0; i < v[x].size(); ++i)
    if (v[x][i] != y) calc(v[x][i], x, nv);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  memset(dp, -1, sizeof dp);
  for (int i = 2; i <= n; ++i) {
    cin >> t;
    v[i].push_back(t);
    v[t].push_back(i);
  }
  ans[1] = dfs(1, 0);
  calc(1, 0, ans[1]);
  for (int i = 1; i <= n; ++i) cout << ans[i] << " ";
}
