#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int maxn = 100000 * 2 + 10;
vector<long long> v[maxn], pre[maxn], pas[maxn];
long long dp[maxn], n, ans[maxn], par[maxn];
void dfs(int x, int p) {
  par[x] = p;
  long long c = 1;
  long long p1 = 1, p2 = 1;
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i] != p) {
      dfs(v[x][i], x);
      c *= (dp[v[x][i]] + 1);
      c %= mod;
    }
  }
  dp[x] = c;
  p2 = 1;
  for (int i = 0; i < v[x].size(); i++)
    if (p != v[x][i]) {
      pre[x].push_back(p1);
      p1 *= (dp[v[x][i]] + 1);
      p1 %= mod;
    }
  for (int i = v[x].size() - 1; i >= 0; i--)
    if (p != v[x][i]) {
      pas[x].push_back(p2);
      p2 *= (dp[v[x][i]] + 1);
      p2 %= mod;
    }
  reverse(pas[x].begin(), pas[x].end());
}
void go(int x) {
  long long oldv = dp[x], o = 0, oldv2;
  ans[x] = dp[x];
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i] != par[x]) {
      oldv = dp[x];
      dp[x] = (pre[x][i - o] * pas[x][i - o]) % mod;
      oldv2 = dp[v[x][i]];
      if (par[x] != 0) dp[x] = (dp[x] * (dp[par[x]] + 1)) % mod;
      dp[v[x][i]] *= (dp[x] + 1);
      dp[v[x][i]] %= mod;
      go(v[x][i]);
      dp[v[x][i]] = oldv2;
      dp[x] = oldv;
    } else
      o = 1;
  }
  dp[x] = oldv;
}
int main() {
  dp[0] = 1;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    v[x].push_back(i);
    v[i].push_back(x);
  }
  dfs(1, 0);
  go(1);
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
  cout << endl;
  return 0;
}
