#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
long long dp[100009][2];
int n, x;
vector<int> ed[100009];
int b[100009];
long long ans;
void dfs(int u, int fa) {
  if (b[u])
    dp[u][1] = 1;
  else
    dp[u][0] = 1;
  for (int i = 0; i < ed[u].size(); i++) {
    int v = ed[u][i];
    if (v == fa) continue;
    dfs(v, u);
    dp[u][1] = (dp[u][1] * (dp[v][0] + dp[v][1]) + dp[u][0] * dp[v][1]) % mod;
    dp[u][0] = (dp[u][0] * (dp[v][0] + dp[v][1])) % mod;
  }
}
int main() {
  ans = 1;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x;
    ed[x].push_back(i);
    ed[i].push_back(x);
  }
  for (int i = 0; i < n; i++) cin >> b[i];
  dfs(0, -1);
  cout << dp[0][1] << endl;
}
