func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( O2 )   using namespace std;   const int MAXN = 1e6 + 10;   const long long MOD = 1e9 + 7;   const long long MOD2 = 998244353;   const long long INF = 8e18;   const int LOG = 22;   long long pw(long long a, long long b, long long mod) {     return (!b ? 1                : (b & 1 ? (a * pw(a * a % mod, b / 2, mod)) % mod                         : pw(a * a % mod, b / 2, mod)));   }   long long dp[2][MAXN];   int x[MAXN];   vector<int> G[MAXN];   void DFS(int v, int par) {     dp[0][v] = 1;     dp[1][v] = 0;     for (auto u : G[v]) {       if (u == par) {         continue;       }       DFS(u, v);       dp[1][v] = (dp[1][v] * dp[0][u]) % MOD;       dp[1][v] = (dp[1][v] + dp[1][u] * dp[0][v]) % MOD;       dp[0][v] = (dp[0][v] * dp[0][u]) % MOD;     }     if (x[v]) {       dp[1][v] = dp[0][v];     } else {       dp[0][v] = (dp[0][v] + dp[1][v]) % MOD;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int n;     cin >> n;     for (int i = 1; i < n; i++) {       int a;       cin >> a;       G[a].push_back(i);       G[i].push_back(a);     }     for (int i = 0; i < n; i++) {       cin >> x[i];     }     DFS(0, -1);     cout << dp[1][0] <<   n ;     return 0;   }   