#include <bits/stdc++.h>
using namespace std;
double eps = 1e-9;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int N = 1e5 + 7;
long long dp[N][2];
vector<int> g[N];
int x[N];
void dfs(int v, int p) {
  dp[v][0] = 1;
  dp[v][1] = 0;
  for (int to : g[v]) {
    if (to != p) {
      dfs(to, v);
      dp[v][1] = (dp[v][1] * dp[to][0]) % MOD;
      dp[v][1] = (dp[v][1] + dp[v][0] * dp[to][1] % MOD) % MOD;
      dp[v][0] = (dp[v][0] * dp[to][0]) % MOD;
    }
  }
  if (x[v])
    dp[v][1] = dp[v][0];
  else
    dp[v][0] += dp[v][1];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n - 1); ++i) {
    int j;
    cin >> j;
    g[i + 1].push_back(j);
    g[j].push_back(i + 1);
  }
  for (int i = 0; i < (int)(n); ++i) cin >> x[i];
  dfs(0, 0);
  cout << dp[0][1] << endl;
}
