#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:10240000,10240000")
using namespace std;
const int dx[8] = {0, 0, -1, 1, 1, 1, -1, -1};
const int dy[8] = {-1, 1, 0, 0, 1, -1, 1, -1};
const int maxn = 2e5 + 7;
const int md = 1e9 + 7;
const int inf = 1e9 + 7;
const long long inf_L = 1e18 + 7;
const double pi = acos(-1.0);
const double eps = 1e-6;
template <class T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <class T>
bool max_update(T &a, const T &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool min_update(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
T condition(bool f, T a, T b) {
  return f ? a : b;
}
template <class T>
void copy_arr(T a[], T b[], int n) {
  for (int i = 0; i < (n); i++) a[i] = b[i];
}
int make_id(int x, int y, int n) { return x * n + y; }
struct Graph {
  vector<vector<int> > G;
  void clear() { G.clear(); }
  void resize(int n) { G.resize(n + 2); }
  void add(int u, int v) { G[u].push_back(v); }
  vector<int> &operator[](int u) { return G[u]; }
};
Graph G, pre, suf;
int fa[maxn], f[maxn], ans[maxn], id[maxn], g[maxn];
void dfs(int n) {
  f[n] = 1;
  int sz = G[n].size();
  for (int i = 0; i < (sz); i++) {
    int v = G[n][i];
    dfs(v);
    f[n] = (long long)f[n] * (1 + f[v]) % md;
  }
}
void getAns(int n) {
  int sz = G[n].size();
  int fn = fa[n], in = id[n];
  pre[n].resize(sz + 2);
  suf[n].resize(sz + 2);
  pre[n][0] = suf[n][sz + 1] = 1;
  if (n == 1) {
    ans[n] = f[n];
    g[n] = 1;
  } else {
    g[n] =
        (1 + (long long)pre[fn][in - 1] % md * suf[fn][in + 1] % md * g[fn]) %
        md;
    ans[n] = (long long)f[n] * g[n] % md;
  }
  for (int i = 0; i < (sz); i++) {
    int v = G[n][i];
    pre[n][i + 1] = (long long)pre[n][i] * (1 + f[v]) % md;
  }
  for (int i = sz - 1; i >= 0; i--) {
    int v = G[n][i];
    suf[n][i + 1] = (long long)suf[n][i + 2] * (1 + f[v]) % md;
  }
  for (int i = 0; i < (sz); i++) {
    int v = G[n][i];
    getAns(v);
  }
}
int main() {
  int n;
  cin >> n;
  G.resize(n);
  pre.resize(n);
  suf.resize(n);
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    G.add(x, i);
    fa[i] = x;
    id[i] = G[x].size();
  }
  dfs(1);
  getAns(1);
  for (int i = 1; i <= (n); i++) printf("%d%c", ans[i], i == n ? '\n' : ' ');
  return 0;
}
