#include <bits/stdc++.h>
using namespace std;
int mod = (int)1e9 + 7;
void dfs(int v, int p, list<int>* adj, int* c, long long** dp) {
  if (c[v] == 1) {
    dp[0][v] = 0;
    dp[1][v] = 1;
  } else {
    dp[0][v] = 1;
    dp[1][v] = 0;
  }
  for (auto i : adj[v]) {
    if (i == p) continue;
    dfs(i, v, adj, c, dp);
    long long zero = dp[0][v], one = dp[1][v];
    dp[0][v] = zero * dp[0][i];
    dp[0][v] %= mod;
    dp[1][v] = (one * dp[0][i]) % mod + (zero * dp[1][i]) % mod;
    dp[1][v] %= mod;
    dp[0][v] += zero * dp[1][i];
    dp[0][v] %= mod;
    dp[1][v] += one * dp[1][i];
    dp[1][v] %= mod;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  list<int>* adj = new list<int>[n];
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    adj[i].push_back(a);
    adj[a].push_back(i);
  }
  int* c = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  long long** dp = new long long*[2];
  dp[0] = new long long[n]();
  dp[1] = new long long[n]();
  dfs(0, -1, adj, c, dp);
  cout << dp[1][0] << endl;
  return 0;
}
