#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
struct node {
  int to, next;
} edge[maxn << 1];
int head[maxn], ecnt;
void add(int from, int to) {
  edge[++ecnt].to = to;
  edge[ecnt].next = head[from];
  head[from] = ecnt;
}
long long l[maxn];
long long dp[maxn];
long long dp2[maxn];
bool vis[maxn];
long long inv(long long x) {
  long long t = mod - 2, ans = 1;
  while (t) {
    if (t & 1) {
      ans = ans * x % mod;
    }
    t >>= 1;
    x = x * x % mod;
  }
  return ans;
}
void dfs(int root, int par) {
  dp[root] = 1;
  bool ok = false;
  for (int i = head[root]; i != 0; i = edge[i].next) {
    int son = edge[i].to;
    if (son != par) {
      dfs(son, root);
      if (dp[son] + 1 == mod && !ok) {
        ok = true;
        vis[son] = true;
      } else {
        dp[root] = dp[root] * (dp[son] + 1) % mod;
      }
    }
  }
  if (ok) {
    l[root] = dp[root];
    dp[root] = 0;
  }
}
void dfs2(int root, int par) {
  dp2[root]++;
  for (int i = head[root]; i != 0; i = edge[i].next) {
    int son = edge[i].to;
    if (son != par) {
      if (!vis[son]) {
        long long t = inv(dp[son] + 1);
        dp2[son] = dp2[root] * dp[root] % mod * t % mod;
      } else {
        dp2[son] = dp2[root] * l[root] % mod;
      }
      dfs2(son, root);
    }
  }
}
void init() {
  memset(dp, 0, sizeof dp);
  memset(dp2, 0, sizeof dp2);
  memset(vis, false, sizeof vis);
  memset(head, 0, sizeof head);
  ecnt = 0;
}
int main() {
  init();
  int n;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int p;
    scanf("%d", &p);
    add(p, i);
    add(i, p);
  }
  dfs(1, 0);
  dfs2(1, 0);
  for (int i = 1; i <= n; i++) {
    printf("%d ", dp[i] * dp2[i] % mod);
  }
  return 0;
}
