#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int N = (int)2e5 + 10, M = (int)1e9 + 7;
int n, dp1[N], dp2[N], dp[N], siz[N], pre[N], suf[N];
vector<int> ed[N];
void dfs1(int u) {
  siz[u] = 1;
  dp1[u] = 1;
  for (int i = 0; i < ed[u].size(); i++) {
    int v = ed[u][i];
    dfs1(v);
    siz[u] += siz[v];
    dp1[u] = (LL)dp1[u] * ((1 + dp1[v]) % M) % M;
    if (i > 0) {
      int p = ed[u][i - 1];
      pre[v] = (LL)pre[p] * (1 + dp1[p]) % M;
    }
  }
  for (int i = (int)ed[u].size() - 2; i >= 0; i--) {
    int v = ed[u][i], p = ed[u][i + 1];
    suf[v] = (LL)suf[p] * (1 + dp1[p]) % M;
  }
}
void dfs2(int u) {
  dp[u] = (LL)dp1[u] * dp2[u] % M;
  for (int v : ed[u]) {
    LL val = (LL)pre[v] * suf[v] % M;
    dp2[v] = (1 + (LL)dp2[u] * val % M) % M;
    dfs2(v);
  }
}
int main() {
  scanf("%d", &n);
  int u, v;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &u);
    ed[u].push_back(i);
  }
  fill(pre + 1, pre + n + 1, 1);
  fill(suf + 1, suf + n + 1, 1);
  dp2[1] = 1;
  dfs1(1);
  dfs2(1);
  for (int i = 1; i <= n; i++) printf("%d ", dp[i]);
  puts("");
}
