#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
int color[100005];
int n;
int dp[100005][2];
void go(int u, int p) {
  for (int i = 0; i < adj[u].size(); ++i) {
    int v = adj[u][i];
    if (v == p) continue;
    go(v, u);
  }
  if (color[u])
    dp[u][1] = 1;
  else
    dp[u][0] = 1;
  for (int i = 0; i < adj[u].size(); ++i) {
    int v = adj[u][i];
    if (v == p) continue;
    int nxt0 = 0, nxt1 = 0;
    nxt0 = (long long)dp[u][0] * (dp[v][0] + dp[v][1]) % 1000000007;
    nxt1 = ((long long)dp[u][0] * dp[v][1] +
            (long long)dp[u][1] * (dp[v][0] + dp[v][1]) % 1000000007) %
           1000000007;
    dp[u][0] = nxt0;
    dp[u][1] = nxt1;
  }
}
int main() {
  scanf("%d", &n);
  for (int u = 1; u < n; ++u) {
    int v;
    scanf("%d", &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 0; i < n; ++i) scanf("%d", color + i);
  go(0, -1);
  printf("%d\n", dp[0][1]);
}
