#include <bits/stdc++.h>
using namespace std;
vector<long long> adjList[200005];
long long x[200005], n, dp[200005][2];
long long FastMod(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b = b >> 1;
  }
  return res;
}
void dfs(long long node, long long par) {
  long long val = 1;
  for (auto neighbour : adjList[node]) {
    if (neighbour != par) {
      dfs(neighbour, node);
      val = (val * (dp[neighbour][0] + dp[neighbour][1])) % 1000000007;
    }
  }
  if (x[node] == 1) {
    dp[node][0] = 0;
    dp[node][1] = val;
  } else {
    dp[node][0] = val;
    long long temp = 1;
    for (auto neighbour : adjList[node]) {
      if (neighbour != par) {
        long long temp = (dp[neighbour][0] + dp[neighbour][1]) % 1000000007;
        temp = FastMod(temp, 1000000007 - 2);
        temp = (temp * dp[node][0]) % 1000000007;
        temp = (temp * dp[neighbour][1]) % 1000000007;
        dp[node][1] = (dp[node][1] + temp) % 1000000007;
      }
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long x;
    cin >> x;
    adjList[i + 1].push_back(x);
    adjList[x].push_back(i + 1);
  }
  for (long long i = 0; i < n; i++) cin >> x[i];
  dfs(0, -1);
  cout << dp[0][1] << "\n";
  return 0;
}
