#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T mod_v(T num) {
  if (num >= 0)
    return num % 1000000007;
  else
    return (num % 1000000007 + 1000000007) % 1000000007;
}
template <class T>
inline T gcd(T a, T b) {
  a = abs(a);
  b = abs(b);
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}
template <class T>
T fast_pow(T n, T p) {
  if (p == 0) return 1;
  if (p % 2) {
    T g = mod_v(mod_v(n) * mod_v(fast_pow(n, p - 1)));
    return g;
  } else {
    T g = fast_pow(n, p / 2);
    g = mod_v(mod_v(g) * mod_v(g));
    return g;
  }
}
template <class T>
inline T modInverse(T n) {
  return fast_pow(n, 1000000007 - 2LL);
}
bool equalTo(double a, double b) {
  if (fabs(a - b) <= 1e-9)
    return true;
  else
    return false;
}
bool notEqual(double a, double b) {
  if (fabs(a - b) > 1e-9)
    return true;
  else
    return false;
}
bool lessThan(double a, double b) {
  if (a + 1e-9 < b)
    return true;
  else
    return false;
}
bool lessThanEqual(double a, double b) {
  if (a < b + 1e-9)
    return true;
  else
    return false;
}
bool greaterThan(double a, double b) {
  if (a > b + 1e-9)
    return true;
  else
    return false;
}
bool greaterThanEqual(double a, double b) {
  if (a + 1e-9 > b)
    return true;
  else
    return false;
}
template <class T>
inline int in(register T& num) {
  register char c = 0;
  num = 0;
  bool n = false;
  while (c < 33) c = getchar();
  while (c > 33) {
    if (c == '-')
      n = true;
    else
      num = num * 10 + c - '0';
    c = getchar();
  }
  num = n ? -num : num;
  return 1;
}
int n;
vector<int> lst[200005];
long long cnt[2000005];
long long res[200005];
void dfs(int nod, int par) {
  cnt[nod] = 1;
  for (int i : lst[nod]) {
    if (i == par) continue;
    dfs(i, nod);
    cnt[nod] = mod_v(cnt[nod] * mod_v(cnt[i] + 1));
  }
}
void re(int nod, int par, long long tmp) {
  res[nod] = mod_v(tmp * cnt[nod]);
  vector<int> later;
  for (int i : lst[nod]) {
    if (i == par) continue;
    if (cnt[i] + 1 == 1000000007) {
      later.push_back(i);
      continue;
    }
    long long V = mod_v(res[nod] * modInverse(cnt[i] + 1));
    tmp = mod_v(tmp * (cnt[i] + 1));
    re(i, nod, mod_v(V + 1));
  }
  for (int i : later) {
    re(i, nod, (((int)later.size()) == 1 ? mod_v(tmp + 1) : 1));
  }
}
int main() {
  int n;
  in(n);
  int v;
  for (int i = 2; i <= n; i++) {
    in(v);
    lst[v].push_back(i);
    lst[i].push_back(v);
  }
  dfs(1, 0);
  re(1, 0, 1);
  for (int i = 1; i <= n; i++) cout << res[i] << " ";
  return 0;
}
