#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, w = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * w;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const long long maxn = 1e5 + 5;
const long long mod = 1e9 + 7;
const long long inf = 1e9;
inline long long min(long long x, long long y) { return x < y ? x : y; }
inline long long max(long long x, long long y) { return x > y ? x : y; }
struct node {
  long long nxt, to;
} edge[maxn << 1];
long long n, tot, head[maxn], f[maxn], g[maxn];
inline void addedge(long long u, long long v) {
  edge[++tot] = (node){head[u], v}, head[u] = tot;
}
inline void dfs(long long u, long long fath) {
  for (long long i = head[u]; i; i = edge[i].nxt) {
    long long v = edge[i].to;
    if (v == fath) continue;
    dfs(v, u);
    f[u] = (f[u] * (f[v] + g[v]) % mod + g[u] * f[v] % mod) % mod;
    g[u] = g[u] * (f[v] + g[v]) % mod;
  }
}
signed main(void) {
  n = read();
  for (long long i = 2, fath; i <= n; i++) {
    fath = read() + 1;
    addedge(fath, i), addedge(i, fath);
  }
  for (long long i = 1, col; i <= n; i++) {
    col = read();
    if (col == 1)
      f[i] = 1;
    else
      g[i] = 1;
  }
  dfs(1, 0);
  printf("%lld\n", f[1]);
  return 0;
}
