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