#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int n, a[100005];
vector<int> edges[100005];
long long dp[100005][2];
void solve(int x, int px) {
  dp[x][0] = 1LL;
  dp[x][1] = 0LL;
  for (int i = 0; i < edges[x].size(); i++) {
    int y = edges[x][i];
    if (y == px) continue;
    solve(y, x);
    dp[x][1] *= dp[y][0];
    dp[x][1] %= mod;
    dp[x][1] += dp[x][0] * dp[y][1];
    dp[x][1] %= mod;
    dp[x][0] *= dp[y][0];
    dp[x][0] %= mod;
  }
  if (a[x] == 1) {
    dp[x][1] = dp[x][0];
  } else {
    dp[x][0] += dp[x][1];
    dp[x][0] %= mod;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x;
    cin >> x;
    edges[x].push_back(i);
    edges[i].push_back(x);
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  solve(0, -1);
  cout << dp[0][1] << "\n";
  return 0;
}
