#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
const int P = 1000000007;
long long exp(long long a, long long x) {
  long long ans = 1;
  for (; x; x >>= 1) {
    if (x & 1) ans = ans * a % P;
    a = a * a % P;
  }
  return ans;
}
vector<int> ch[N], mul[N];
int dp[N], ans[N];
void init_(int u) {
  long long res = 1;
  for (int i = 0; i <= (int)ch[u].size() - 1; i++) {
    int v = ch[u][i];
    init_(v);
    mul[u].push_back(res);
    res = res * (dp[v] + 1) % P;
  }
  res = 1;
  for (int i = (int)ch[u].size() - 1; i >= 0; i--) {
    int v = ch[u][i];
    mul[u][i] = mul[u][i] * res % P;
    res = res * (dp[v] + 1) % P;
  }
  dp[u] = res;
}
void get_ans(int u, long long d) {
  ans[u] = dp[u] * d % P;
  for (int i = 0; i <= (int)ch[u].size() - 1; i++) {
    int v = ch[u][i];
    get_ans(v, d * mul[u][i] % P + 1);
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int f;
    scanf("%d", &f);
    ch[f].push_back(i);
  }
  init_(1);
  get_ans(1, 1);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
