#include <bits/stdc++.h>
using namespace std;
int n, x, kk, dp[2000005][2], col[2000005], head[2000005];
struct Tree {
  int nxt, to;
} e[2000005];
inline void link(int x, int y) {
  e[++kk].nxt = head[x];
  e[kk].to = y;
  head[x] = kk;
}
void dfs1(int u, int fa) {
  dp[u][col[u]] = 1;
  dp[u][col[u] ^ 1] = 0;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs1(v, u);
    dp[u][1] = 1ll *
               (1ll * dp[u][1] * (dp[v][0] + dp[v][1]) % 1000000007 +
                1ll * dp[u][0] * dp[v][1] % 1000000007) %
               1000000007;
    dp[u][0] = 1ll *
               (1ll * dp[u][0] * dp[v][0] % 1000000007 +
                1ll * dp[u][0] * dp[v][1] % 1000000007) %
               1000000007;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &x);
    x++;
    link(x, i);
  }
  for (int i = 1; i <= n; i++) scanf("%d", &col[i]);
  dfs1(1, -1);
  printf("%d\n", (dp[1][1]) % 1000000007);
  return 0;
}
