func_code_string: #include <bits/stdc++.h>   using namespace std;   int i, j, k, n, m;   int fa[200010], an[200010];   vector<int> a[200010];   pair<int, int> f[200010];   inline void P(int &x, int y) { x = 1ll * x * y % 1000000007; }   inline void merge(pair<int, int> &a, pair<int, int> b) {     P(a.first, b.first);     int g = (2ll * b.first + b.second) % 1000000007;     P(a.second, g);   }   inline void gao(pair<int, int> &a) {     a.second = (a.second - a.first) % 1000000007;   }   inline void ch(pair<int, int> &a, pair<int, int> b) {     a.first = 1ll * a.first * b.first % 1000000007;     a.second = 1ll * a.second * b.second % 1000000007;   }   void dfs(int x) {     f[x] = make_pair(1, 1);     for (auto i : a[x]) {       if (fa[x] == i) continue;       fa[i] = x;       dfs(i);       merge(f[x], f[i]);     }     gao(f[x]);   }   void huan(int x) {     an[x] = (f[x].first + f[x].second) % 1000000007;     int t = 0, i, len = a[x].size() + 5;     vector<pair<int, int> > g(len), f1(len), f2(len);     for (auto i : a[x]) g[++t] = f[i];     f1[0] = make_pair(1, 1);     for (i = 1; i <= t; i++) f1[i] = f1[i - 1], merge(f1[i], g[i]);     f2[t + 1] = make_pair(1, 1);     for (i = t; i; i--) f2[i] = f2[i + 1], merge(f2[i], g[i]);     int _ = 0;     for (auto i : a[x]) {       _++;       if (fa[x] == i) continue;       pair<int, int> v = f1[_ - 1];       ch(v, f2[_ + 1]);       gao(v);       swap(f[x], v);       pair<int, int> tmp = f[i];       f[i].second = (f[i].second + f[i].first) % 1000000007;       merge(f[i], f[x]);       gao(f[i]);       huan(i);       swap(f[x], v);       f[i] = tmp;     }   }   int main() {     scanf( %d , &n);     for (i = 1; i <= n - 1; i++) {       int x;       scanf( %d , &x);       a[x].push_back(i + 1);       a[i + 1].push_back(x);     }     dfs(1);     huan(1);     for (i = 1; i <= n; i++) printf( %d  , (an[i] + 1000000007) % 1000000007);     printf(  n );     return 0;   }   