#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100010];
long long int col[100010];
long long int dp[100010][2];
void dfs(int x, int f) {
  if (col[x] == 1) {
    dp[x][0] = 0;
    dp[x][1] = 1;
  } else {
    dp[x][0] = 1;
    dp[x][1] = 0;
  }
  for (int i = 0; i < adj[x].size(); i++) {
    int y = adj[x][i];
    if (y != f) {
      dfs(y, x);
      long long int no_black = dp[x][0];
      long long int one_black = dp[x][1];
      dp[x][0] = dp[x][1] = 0;
      if (dp[y][1] > 0) {
        dp[x][1] += one_black * dp[y][1];
        dp[x][1] += no_black * dp[y][1];
        dp[x][0] += no_black * dp[y][1];
      }
      if (dp[y][0] > 0) {
        dp[x][1] += one_black * dp[y][0];
        dp[x][0] += no_black * dp[y][0];
      }
      dp[x][0] = dp[x][0] % 1000000007;
      dp[x][1] = dp[x][1] % 1000000007;
    }
  }
  return;
}
int main() {
  int n, x;
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    cin >> x;
    adj[i].push_back(x);
    adj[x].push_back(i);
  }
  for (int i = 0; i < n; i++) cin >> col[i];
  dfs(0, -1);
  cout << dp[0][1] << endl;
  return 0;
}
