#include <bits/stdc++.h>
using namespace std;
int N, M, p[200100], d[200100], u[200100];
vector<int> m[200100];
int pw(int x, int y) {
  if (y == 0) {
    return 1;
  }
  int z = pw(x, y / 2);
  z = (1LL * z * z) % 1000000007;
  if (y % 2) {
    z = (1LL * z * x) % 1000000007;
  }
  return z;
}
int inv(int x) { return pw(x, 1000000007 - 2); }
int main() {
  scanf("%d", &N);
  p[1] = 0;
  for (int i = 2; i <= N; ++i) {
    scanf("%d", &p[i]);
  }
  for (int i = 1; i <= N; ++i) {
    d[i] = 1;
    u[i] = 1;
    m[p[i]].push_back(i);
  }
  for (int i = N; i >= 1; --i) {
    d[p[i]] = (1LL * d[p[i]] * (d[i] + 1)) % 1000000007;
  }
  for (int i = 2; i <= N; ++i) {
    int x = 1;
    if ((d[i] + 1) % 1000000007 == 0) {
      for (int j = 0; j < m[p[i]].size(); ++j) {
        int y = m[p[i]][j];
        if (y == i) continue;
        x = (1LL * x * (d[y] + 1)) % 1000000007;
      }
    } else {
      x = (1LL * d[p[i]] * inv(d[i] + 1)) % 1000000007;
    }
    u[i] = (1LL * u[p[i]] * x + 1) % 1000000007;
  }
  for (int i = 1; i <= N; ++i) {
    int x = (1LL * d[i] * u[i]) % 1000000007;
    printf("%d ", x);
  }
  return 0;
}
