#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long dp[100006][2];
long long a[100006];
vector<int> lista[100005];
void dfs(int nod, int daddy) {
  dp[nod][0] = 1;
  dp[nod][1] = 0;
  for (int i = 0; i < lista[nod].size(); i++) {
    int x = lista[nod][i];
    if (x == daddy) continue;
    dfs(x, nod);
    dp[nod][1] = (dp[nod][1] * dp[x][0] + dp[nod][0] * dp[x][1]) % mod;
    dp[nod][0] = (dp[x][0] * dp[nod][0]) % mod;
  }
  if (a[nod])
    dp[nod][1] = dp[nod][0];
  else
    dp[nod][0] = (dp[nod][1] + dp[nod][0]) % mod;
}
int main() {
  long long t, n, i, nr;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> nr;
    lista[i].push_back(nr);
    lista[nr].push_back(i);
  }
  for (i = 0; i < n; i++) cin >> a[i];
  dfs(0, -1);
  cout << dp[0][1];
  return 0;
}
