#include <bits/stdc++.h>
const int M = 100010, mod = 1e9 + 7;
int n;
int fa[M], col[M];
template <typename T>
inline void read(T &x) {
  x = 0;
  char ch = getchar();
  int f = 1;
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  x *= f;
}
int head[M], tot = 0;
struct edge {
  int to, next;
} e[M];
inline void add(int u, int v) {
  e[++tot] = (edge){v, head[u]};
  head[u] = tot;
}
long long dp[M][2];
void dfs(int pos) {
  if (col[pos] == 1)
    dp[pos][1] = 1;
  else
    dp[pos][0] = 1;
  for (int i = head[pos], v; i; i = e[i].next)
    if ((v = e[i].to) != fa[pos]) {
      dfs(v);
      dp[pos][1] = (dp[pos][1] * (dp[v][0] + dp[v][1]) % mod +
                    dp[pos][0] * dp[v][1] % mod) %
                   mod;
      dp[pos][0] = dp[pos][0] * (dp[v][0] + dp[v][1]) % mod;
    }
}
int main() {
  read(n);
  for (int i = 2; i <= n; i++) read(fa[i]), fa[i]++, add(fa[i], i);
  for (int i = 1; i <= n; i++) read(col[i]);
  dfs(1);
  printf("%d\n", dp[1][1]);
  return 0;
}
