#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX_N = 200100;
int d[MAX_N];
int p[MAX_N];
vector<int> A[MAX_N];
void dfs1(int nod) {
  d[nod] = 1;
  for (auto it : A[nod]) {
    dfs1(it);
    d[nod] = (1LL * d[nod] * (d[it] + 1)) % MOD;
  }
}
void dfs2(int nod, int dad) {
  p[nod] = (1LL * d[nod] * (dad + 1)) % MOD;
  vector<int> v1, v2;
  v1.push_back(1);
  for (auto it : A[nod]) {
    v1.push_back(d[it] + 1);
  }
  v1.push_back(1);
  v2 = v1;
  reverse(v2.begin(), v2.end());
  for (int i = 1; i < (int)v1.size(); i++) {
    v1[i] = (1LL * v1[i] * v1[i - 1]) % MOD;
  }
  for (int i = 1; i < (int)v2.size(); i++) {
    v2[i] = (1LL * v2[i] * v2[i - 1]) % MOD;
  }
  reverse(v2.begin(), v2.end());
  for (int i = 1; i <= (int)A[nod].size(); i++) {
    dfs2(A[nod][i - 1],
         ((1LL * (dad + 1) * v1[i - 1]) % MOD * v2[i + 1]) % MOD);
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int a;
    cin >> a;
    A[a].push_back(i);
  }
  dfs1(1);
  dfs2(1, 0);
  for (int i = 1; i <= n; i++) {
    cout << p[i] << ' ';
  }
}
