#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
const int maxn = 2e5 + 100;
const int inf = (int)1e9;
long long power(long long a, long long b) {
  if (b == 0) return 1;
  long long ret = power(a, b / 2);
  ret *= ret;
  ret %= mod;
  if (b & 1) ret *= a;
  return ret % mod;
}
vector<int> v[maxn];
vector<long long> par[maxn], rev[maxn];
long long dp_up[maxn], dp_down[maxn];
void dfs_down(int u, int p = -1, long long tmp = 0) {
  dp_up[u] = 1;
  if (p != -1) {
    dp_up[u] = dp_up[p] * tmp % mod + 1 % mod;
    dp_up[u] %= mod;
  }
  for (int i = 0; i < v[u].size(); i++) {
    int w = v[u][i];
    long long cmp = 1;
    if (i > 0) cmp *= par[u][i - 1];
    if (i < v[u].size() - 1) cmp *= rev[u][i + 1];
    cmp %= mod;
    dfs_down(w, u, cmp);
  }
}
void dfs_up(int u) {
  dp_down[u] = 1;
  for (auto w : v[u]) {
    dfs_up(w);
    if (par[u].empty())
      par[u].push_back((dp_down[w] + 1) % mod);
    else
      par[u].push_back(par[u].back() * (dp_down[w] + 1) % mod);
    dp_down[u] *= (dp_down[w] + 1);
    dp_down[u] %= mod;
  }
  for (int i = v[u].size() - 1; i >= 0; i--) {
    int w = v[u][i];
    if (rev[u].empty())
      rev[u].push_back((dp_down[w] + 1) % mod);
    else
      rev[u].push_back((dp_down[w] + 1) * rev[u].back() % mod);
  }
  reverse(rev[u].begin(), rev[u].end());
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int p;
    cin >> p;
    v[p].push_back(i);
  }
  dfs_up(1);
  dfs_down(1);
  for (int i = 1; i <= n; i++) cout << dp_up[i] * dp_down[i] % mod << " ";
}
