#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200001];
vector<int> x(200001);
vector<vector<long long> > dp(200001, vector<long long>(2));
void dfs(int node, int parent) {
  int i;
  dp[node][0] = 1;
  dp[node][1] = 0;
  for (i = 0; i < adj[node].size(); i++) {
    if (adj[node][i] == parent) continue;
    dfs(adj[node][i], node);
    dp[node][1] = (dp[node][1] * dp[adj[node][i]][0]) % 1000000007;
    dp[node][1] =
        (dp[node][1] + (dp[node][0] * dp[adj[node][i]][1]) % 1000000007) %
        1000000007;
    dp[node][0] = (dp[node][0] * dp[adj[node][i]][0]) % 1000000007;
  }
  if (x[node] == 1)
    dp[node][1] = dp[node][0];
  else
    dp[node][0] = (dp[node][0] + dp[node][1]) % 1000000007;
}
int main() {
  long long n, i, u, v;
  cin >> n;
  for (i = 1; i <= n - 1; i++) {
    cin >> u;
    adj[i].push_back(u);
    adj[u].push_back(i);
  }
  for (i = 0; i < n; i++) {
    cin >> u;
    x[i] = u;
  }
  dfs(0, -1);
  cout << dp[0][1] << " ";
  return 0;
}
