#include <bits/stdc++.h>
using namespace std;
vector<int> v[100001];
int bl[100001];
long long int dp[100001][2];
int mar[100001];
void dfs(int i) {
  mar[i] = 1;
  long long int old0, old1;
  if (bl[i]) {
    dp[i][0] = old0 = 0;
    dp[i][1] = old1 = 1;
  } else {
    dp[i][0] = old0 = 1;
    dp[i][1] = old1 = 0;
  }
  for (int j = 0; j < v[i].size(); j++) {
    int ne = v[i][j];
    if (!mar[ne]) {
      dfs(ne);
      if (bl[i]) {
        dp[i][1] *= (dp[ne][0] + dp[ne][1]) % 1000000007;
        dp[i][1] %= 1000000007;
      } else {
        dp[i][1] = (old1 * (dp[ne][0] + dp[ne][1])) % 1000000007;
        dp[i][1] %= 1000000007;
        dp[i][1] += (old0 * (dp[ne][1])) % 1000000007;
        dp[i][1] %= 1000000007;
        dp[i][0] *= (dp[ne][0] + dp[ne][1]) % 1000000007;
        dp[i][0] %= 1000000007;
      }
      old0 = dp[i][0];
      old1 = dp[i][1];
    }
  }
}
int main() {
  memset(dp, 0, sizeof(dp));
  memset(mar, 0, sizeof(mar));
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a;
    cin >> a;
    v[a].push_back(i + 1);
    v[i + 1].push_back(a);
  }
  for (int i = 0; i < n; i++) cin >> bl[i];
  dfs(0);
  cout << dp[0][1];
  return 0;
}
