func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxN = (int)2E5 + 5;   const long long mdls = (long long)1E9 + 7;   vector<int> Adj[maxN];   vector<long long> suff[maxN], pref[maxN];   long long f[maxN], g[maxN], h[maxN];   int n;   void DFS(int u) {     f[u] = 1;     for (int i = 0, sz = Adj[u].size(); i < sz; ++i) {       int v = Adj[u][i];       DFS(v);       f[u] = (f[u] * (f[v] + 1)) % mdls;     }     int sz = Adj[u].size();     suff[u].resize(sz);     pref[u].resize(sz);     long long temp = 1;     for (int i = 0; i < sz; ++i) {       temp = (temp * (f[Adj[u][i]] + 1)) % mdls;       pref[u][i] = temp;     }     temp = 1;     for (int i = sz - 1; i >= 0; --i) {       temp = (temp * (f[Adj[u][i]] + 1)) % mdls;       suff[u][i] = temp;     }   }   void DFS2(int u) {     for (int i = 0, sz = Adj[u].size(); i < sz; ++i) {       int v = Adj[u][i];       h[v] = h[u];       if (i > 0) h[v] = (h[v] * pref[u][i - 1]) % mdls;       if (i < sz - 1) h[v] = (h[v] * suff[u][i + 1]) % mdls;       h[v] = (h[v] + 1) % mdls;       g[v] = (f[v] * h[v]) % mdls;       DFS2(v);     }   }   int main() {     scanf( %d , &n);     for (int u = 1; u <= n; ++u) Adj[u].clear();     for (int v = 2; v <= n; ++v) {       int u;       scanf( %d , &u);       Adj[u].push_back(v);     }     DFS(1);     h[1] = 1;     g[1] = f[1];     DFS2(1);     for (int u = 1; u <= n; ++u) printf( %I64d  , g[u]);     printf(  n );     return 0;   }   