#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 5;
const long long MOD = (long long)1e9 + 7;
vector<int> adj[N];
int n, x[N];
long long dp[N][2];
void dfs(int u) {
  dp[u][0] = 1LL;
  dp[u][1] = 0LL;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    dfs(v);
    dp[u][1] = (dp[u][1] % MOD * dp[v][0] % MOD) % MOD;
    dp[u][1] =
        (dp[u][1] % MOD + ((dp[u][0] % MOD * dp[v][1] % MOD) % MOD) % MOD) %
        MOD;
    dp[u][0] = (dp[u][0] % MOD * dp[v][0] % MOD) % MOD;
  }
  if (x[u] == 1)
    dp[u][1] = dp[u][0];
  else
    dp[u][0] = (dp[u][0] % MOD + dp[u][1] % MOD) % MOD;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int p;
    scanf("%d", &p);
    adj[p].push_back(i);
  }
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  dfs(0);
  printf("%lld\n", dp[0][1] % MOD);
  return 0;
}
