#include <bits/stdc++.h>
using namespace std;
long long n, u, col[300005], dp[300005][2];
vector<long long> graph[300005];
void dfs(long long u) {
  dp[u][col[u]] = 1;
  for (long long i = 0; i < graph[u].size(); i++) {
    long long v = graph[u][i];
    dfs(v);
    dp[u][1] = (((dp[u][1] * dp[v][0]) % 1000000007 +
                 (dp[u][0] * dp[v][1]) % 1000000007) %
                    1000000007 +
                (dp[u][1] * dp[v][1]) % 1000000007) %
               1000000007;
    dp[u][0] = (dp[u][0] * ((dp[v][0] + dp[v][1]) % 1000000007)) % 1000000007;
  }
}
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i < n; i++) {
    scanf("%lld", &u);
    graph[u].push_back(i);
  }
  for (long long i = 0; i < n; i++) scanf("%lld", &col[i]);
  dfs(0);
  printf("%lld\n", dp[0][1]);
  return 0;
}
