func_code_string: #include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   void read(int& x) {     x = 0;     int f = 1;     char ch = getchar();     while ((ch <  0  || ch >  9 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) f = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     x *= f;   }   int n, f[200005], g[200005], els[200005];   vector<int> E[200005];   int power(int a, int b, int p) {     int s = 1, w = a;     while (b) {       if (b & 1) s = (long long)s * w % p;       w = (long long)w * w % p;       b >>= 1;     }     return s;   }   vector<int> F[200005], B[200005];   void dfs(int now) {     f[now] = 1;     for (int i = (0); i < (E[now].size()); i++) {       dfs(E[now][i]),           f[now] = (long long)f[now] * (f[E[now][i]] + 1) % 1000000007;       F[now].push_back(f[E[now][i]] + 1), B[now].push_back(f[E[now][i]] + 1);     }     for (int i = (1); i < (E[now].size()); i++)       F[now][i] = (long long)F[now][i - 1] * F[now][i] % 1000000007;     for (int i = (E[now].size() - 2); i >= (0); i--)       B[now][i] = (long long)B[now][i + 1] * B[now][i] % 1000000007;     if (E[now].size() == 1) {       els[E[now][0]] = 1;       return;     }     for (int i = (0); i < (E[now].size()); i++) {       if (i == 0)         els[E[now][i]] = B[now][i + 1];       else if (i + 1 == E[now].size())         els[E[now][i]] = F[now][i - 1];       else         els[E[now][i]] = (long long)B[now][i + 1] * F[now][i - 1] % 1000000007;     }   }   void work(int now) {     for (int i = (0); i < (E[now].size()); i++) {       g[E[now][i]] = ((long long)g[now] * els[E[now][i]] + 1) % 1000000007;       work(E[now][i]);     }   }   int main() {     read(n);     for (int i = (2); i <= (n); i++) {       int x;       read(x);       E[x].push_back(i);     }     dfs(1);     g[1] = 1;     work(1);     for (int i = (1); i <= (n); i++)       printf( %lld  , (long long)f[i] * g[i] % 1000000007);     printf(  n );     return 0;   }   