#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int n;
long long dp[100005][2];
int c[100005];
vector<int> edge[100005];
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x;
    cin >> x;
    edge[x].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = n - 1; i >= 0; i--) {
    long long a0 = 0, a1 = 0;
    if (c[i] == 0)
      a0++;
    else
      a1++;
    for (int j = 0; j < edge[i].size(); j++) {
      int x = edge[i][j];
      long long a01 = (a0 * dp[x][0] + a0 * dp[x][1]) % MOD;
      long long a11 = (a1 * dp[x][0] + a1 * dp[x][1] + a0 * dp[x][1]) % MOD;
      a0 = a01;
      a1 = a11;
    }
    dp[i][0] = a0;
    dp[i][1] = a1;
  }
  cout << dp[0][1];
  return 0;
}
