#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> adj[100001];
int color[100001];
long long dp[100001][2];
void dfs(int node) {
  dp[node][0] = 1;
  dp[node][1] = 0;
  for (int X : adj[node]) {
    dfs(X);
    dp[node][1] *= dp[X][0];
    dp[node][1] += dp[node][0] * dp[X][1];
    dp[node][0] *= dp[X][0];
    dp[node][0] %= 1000000007;
    dp[node][1] %= 1000000007;
  }
  if (color[node] == 1)
    dp[node][1] = dp[node][0];
  else
    dp[node][0] += dp[node][1];
}
int main() {
  cin >> N;
  for (int i = 1; i < N; i++) {
    int X;
    cin >> X;
    adj[X].push_back(i);
  }
  for (int i = 0; i < N; i++) cin >> color[i];
  dfs(0);
  cout << dp[0][1] << '\n';
  return 0;
}
