#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100005];
bool visited[100005];
bool black[100005];
long long int dp[100005][2];
long long int p = 1000000007;
void dfs(int n) {
  visited[n] = 1;
  if (black[n]) {
    dp[n][1] = 1;
    dp[n][0] = 0;
  } else {
    dp[n][0] = 1;
    dp[n][1] = 0;
  }
  for (int i = 0; i < graph[n].size(); i++) {
    if (visited[graph[n][i]]) {
      continue;
    } else {
      dfs(graph[n][i]);
      if (black[n] == 1) {
        dp[n][1] = (dp[n][1] * (dp[graph[n][i]][0] + dp[graph[n][i]][1])) % p;
      } else {
        dp[n][1] = (dp[n][1] * (dp[graph[n][i]][0] + dp[graph[n][i]][1])) % p;
        dp[n][1] += (dp[graph[n][i]][1] * dp[n][0]) % p;
        dp[n][0] = (dp[n][0] * (dp[graph[n][i]][0] + dp[graph[n][i]][1])) % p;
      }
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int z;
    cin >> z;
    graph[i + 1].push_back(z);
    graph[z].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) {
    cin >> black[i];
  }
  dfs(0);
  cout << ((dp[0][1]) % p);
}
