func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 200100;   const int mod = 1e9 + 7;   int add(int a, int b) {     a += b;     if (a >= mod) a -= mod;     if (a < 0) a += mod;     return a;   }   int mul(int a, int b) { return 1ll * a * b % mod; }   int N;   int F[maxn];   int Ans[maxn];   vector<int> pre[maxn];   vector<int> suf[maxn];   vector<int> G[maxn];   void DFS(int u, int p = 0) {     F[u] = 1;     vector<int> ch;     for (int v : G[u])       if (v != p) {         DFS(v, u);         F[u] = mul(F[u], add(F[v], 1));         ch.push_back(v);       }     pre[u].resize((int)ch.size());     suf[u].resize((int)ch.size());     for (int i = 0; i < (int)ch.size(); ++i) {       int v = ch[i];       if (i)         pre[u][i] = pre[u][i - 1];       else         pre[u][i] = 1;       pre[u][i] = mul(pre[u][i], add(F[v], 1));     }     for (int i = (int)ch.size() - 1; i >= 0; --i) {       int v = ch[i];       if (i < (int)ch.size() - 1)         suf[u][i] = suf[u][i + 1];       else         suf[u][i] = 1;       suf[u][i] = mul(suf[u][i], add(F[v], 1));     }   }   void dfs(int u, int p = 0, int buf = 1) {     Ans[u] = F[u];     vector<int> ch;     for (int v : G[u])       if (v != p) {         ch.push_back(v);       }     for (int i = 0; i < (int)ch.size(); ++i) {       int v = ch[i];       int nFu = buf;       if (i) nFu = mul(nFu, pre[u][i - 1]);       if (i < (int)ch.size() - 1) nFu = mul(nFu, suf[u][i + 1]);       int tm = F[v];       F[v] = mul(F[v], add(nFu, 1));       dfs(v, u, add(nFu, 1));       F[v] = tm;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> N;     for (int p, i = 2; i <= N; ++i) {       cin >> p;       G[p].push_back(i);       G[i].push_back(p);     }     F[1] = 1;     DFS(1);     dfs(1);     for (int i = 1; i <= N; ++i) cout << Ans[i] <<    ;     return 0;   }   