#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 100005;
const long long MOD = 1000000007;
template <class T>
inline void read(T &x) {
  x = 0;
  int f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    f |= (ch == '-');
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  x = f ? -x : x;
  return;
}
int n, head[N], cnt, x;
long long f[N][2];
struct edge {
  int v, nxt;
} e[N];
inline void add(int u, int v) { e[++cnt] = (edge){v, head[u]}, head[u] = cnt; }
void dfs(int u) {
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    dfs(v);
    f[u][1] = ((f[v][0] + f[v][1]) * f[u][1] % MOD + f[u][0] * f[v][1]) % MOD;
    f[u][0] = f[u][0] * (f[v][1] + f[v][0]) % MOD;
  }
}
int main() {
  read(n);
  for (int i = 2; i <= n; ++i) read(x), add(x + 1, i);
  for (int i = 1; i <= n; ++i) read(x), f[i][x] = 1;
  dfs(1);
  printf("%lld", f[1][1]);
  return 0;
}
