func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long N = 3e5;   const long long P = 1e9 + 7;   long long n;   long long col[N], f[N], g[N];   vector<long long> a[N];   long long read(void) {     long long s = 0, w = 0;     char c = getchar();     while (!isdigit(c)) w |= c ==  - , c = getchar();     while (isdigit(c)) s = s * 10 + c - 48, c = getchar();     return w ? -s : s;   }   void Dfs(long long x, long long fa) {     col[x] ? f[x] = 1 : g[x] = 1;     for (long long i = 0; i < a[x].size(); ++i) {       long long y = a[x][i];       if (y == fa) continue;       Dfs(y, x);       f[x] = (f[x] * (f[y] + g[y]) + g[x] * f[y]) % P;       g[x] = (g[x] * (f[y] + g[y])) % P;     }     return;   }   signed main(void) {     n = read();     for (long long i = 1; i < n; ++i) a[read()].push_back(i);     for (long long i = 0; i < n; ++i) col[i] = read();     Dfs(0, 0);     cout << f[0] << endl;     return 0;   }   