#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 9, M = 1e9 + 7;
vector<int> mp[N];
long long d[N], p[N];
void dfs(int u) {
  d[u] = 1;
  for (int i = 0; i < mp[u].size(); ++i) {
    int to = mp[u][i];
    dfs(to);
    d[u] *= d[to] + 1;
    d[u] %= M;
  }
}
long long po(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) r = r * a % M;
    a = a * a % M;
    b >>= 1;
  }
  return r;
}
long long inv(long long a) { return po(a, M - 2); }
long long L[N], R[N];
void dfs2(int u) {
  L[0] = 1;
  for (int i = 0; i < int(mp[u].size()); ++i) {
    int to = mp[u][i];
    L[i + 1] = L[i] * (d[to] + 1);
    L[i + 1] %= M;
  }
  R[int(mp[u].size()) + 1] = 1;
  for (int i = int(mp[u].size()) - 1; i >= 0; --i) {
    int to = mp[u][i];
    R[i + 1] = R[i + 2] * (d[to] + 1);
    R[i + 1] %= M;
  }
  for (int i = 0; i < int(mp[u].size()); ++i) {
    int to = mp[u][i];
    p[to] = L[i] * R[i + 2] % M * p[u] % M;
    p[to]++;
    p[to] %= M;
  }
  for (int i = 0; i < int(mp[u].size()); ++i) {
    dfs2(mp[u][i]);
  }
}
int n;
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    mp[x].push_back(i);
  }
  p[1] = 1;
  dfs(1);
  dfs2(1);
  for (int i = 1; i <= n; ++i) {
    int o = d[i] * p[i] % M;
    printf("%d ", o);
  }
  return 0;
}
