#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const long long MOD = 1e9 + 7;
int n, fa[N];
long long s1[N], s2[N];
long long dp1[N], dp2[N];
int v[N], nxt[N], head[N];
void dfs1(int x) {
  dp1[x] = 1;
  for (int i = head[x]; i > 0; i = nxt[i]) {
    dfs1(v[i]);
    dp1[x] = dp1[x] * (dp1[v[i]] + 1) % MOD;
  }
}
void dfs2(int x) {
  int cnt = 0;
  for (int i = head[x]; i > 0; i = nxt[i]) s1[++cnt] = (dp1[v[i]] + 1) % MOD;
  s2[cnt] = s1[cnt], s1[0] = s2[0] = s1[cnt + 1] = s2[cnt + 1] = 1;
  for (int i = cnt - 1; i >= 1; i--) s2[i] = (s1[i] * s2[i + 1]) % MOD;
  for (int i = 2; i <= cnt; i++) s1[i] = (s1[i] * s1[i - 1]) % MOD;
  cnt = 0;
  for (int i = head[x]; i > 0; i = nxt[i]) {
    dp2[v[i]] = (dp2[x] + 1) * s1[cnt] % MOD * s2[++cnt + 1] % MOD;
  }
  for (int i = head[x]; i > 0; i = nxt[i]) dfs2(v[i]);
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &fa[i]);
    v[i] = i, nxt[i] = head[fa[i]], head[fa[i]] = i;
  }
  dfs1(1), dfs2(1);
  for (int i = 1; i <= n; i++) printf("%lld ", dp1[i] * (dp2[i] + 1) % MOD);
}
