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