#include <bits/stdc++.h>
using namespace std;
int mod;
int n;
map<int, vector<int> > ch;
int col[100001];
bool seen[100001];
int dp[100001][2];
void dfs(int r) {
  if (seen[r]) return;
  seen[r] = true;
  dp[r][0] = 1;
  dp[r][1] = 0;
  for (int i = 0; i < ch[r].size(); ++i) {
    int u = ch[r][i];
    if (seen[u]) continue;
    dfs(u);
    dp[r][1] = ((dp[r][1] * 1ll) * dp[ch[r][i]][0]) % mod;
    dp[r][1] =
        (dp[r][1] * 1ll + ((1ll * dp[ch[r][i]][1]) * dp[r][0]) % mod) % mod;
    dp[r][0] = ((dp[r][0] * 1ll) * dp[ch[r][i]][0]) % mod;
  }
  if (col[r] == 1) {
    dp[r][1] = dp[r][0];
  } else {
    dp[r][0] = (dp[r][0] * 1ll + dp[r][1]) % mod;
  }
}
int main() {
  mod = 1000000007;
  memset(dp, 0, sizeof dp);
  memset(seen, false, sizeof seen);
  scanf("%d\n", &n);
  int tmp;
  for (int i = 0; i < n - 1; ++i) {
    cin >> tmp;
    ch[tmp].push_back(i + 1);
    ch[i + 1].push_back(tmp);
  }
  cin.get();
  for (int i = 0; i < n; ++i) {
    cin >> col[i];
  }
  dfs(0);
  cout << dp[0][1] << endl;
  return 0;
}
