#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10, mod = 1e9 + 7;
long long dp[maxn], dpu[maxn];
inline long long P(int x, int y) {
  if (y == 0) return 1;
  long long G = P(x, y / 2);
  G = (G * G) % mod;
  if (y & 1) return (1LL * G * x) % mod;
  return G;
}
inline long long Div(int x, int y) {
  if (y == 0) y = mod;
  return (1LL * x * P(y, mod - 2)) % mod;
}
vector<int> v[maxn];
inline void dfs(int x) {
  dp[x] = 1LL;
  for (int i = 0; i < v[x].size(); i++) {
    dfs(v[x][i]);
    dp[x] = (1LL * (dp[v[x][i]] + 1) * dp[x]) % mod;
  }
}
inline void dfs2(int x) {
  vector<long long> p, s;
  p.resize(v[x].size() + 2, 1);
  s.resize(v[x].size() + 2, 1);
  for (int i = 1; i <= v[x].size(); i++)
    p[i] = (p[i - 1] * (dp[v[x][i - 1]] + 1)) % mod;
  for (int i = v[x].size(); i >= 1; i--)
    s[i] = (s[i + 1] * (dp[v[x][i - 1]] + 1)) % mod;
  for (int i = 1; i <= v[x].size(); i++) {
    int k = v[x][i - 1];
    dpu[k] = (1 + ((p[i - 1] * s[i + 1]) % mod) * dpu[x]) % mod;
    dfs2(k);
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    v[x].push_back(i);
  }
  dfs(1);
  dpu[1] = 1;
  dfs2(1);
  for (int i = 1; i <= n; i++) cout << (1LL * dp[i] * dpu[i]) % mod << " ";
  return 0;
}
