#include <bits/stdc++.h>
template <class T>
T read(T &a) {
  a = 0;
  char x = getchar();
  bool f = 0;
  for (; x < '0' || x > '9'; x = getchar()) f |= x == '-';
  for (; x >= '0' && x <= '9'; x = getchar()) a = (a << 3) + (a << 1) + x - '0';
  if (f) a = -a;
  return a;
}
using namespace std;
const int N = 2e5 + 5, MOD = 1e9 + 7;
int nnext[N], v[N], d[N];
int F[N], cnt;
long long f[N][2];
void add(int a, int b) {
  nnext[++cnt] = F[a];
  F[a] = cnt;
  v[cnt] = b;
}
void dfs(int u, int fa) {
  f[u][0] = 1;
  f[u][1] = 0;
  for (int i = F[u]; i; i = nnext[i]) {
    int to = v[i];
    if (to == fa) continue;
    dfs(to, u);
    f[u][1] *= f[to][0];
    f[u][1] += f[to][1] * f[u][0];
    f[u][0] *= f[to][0];
    f[u][1] %= MOD;
    f[u][0] %= MOD;
  }
  if (d[u]) {
    f[u][1] = f[u][0];
  } else {
    f[u][0] += f[u][1];
  }
  f[u][1] %= MOD;
  f[u][0] %= MOD;
}
int main() {
  int n;
  read(n);
  for (int i = 2; i <= n; ++i) {
    int a;
    read(a);
    a++;
    add(a, i);
    add(i, a);
  }
  for (int i = 1; i <= n; ++i) {
    read(d[i]);
  }
  dfs(1, 0);
  printf("%lld\n", f[1][1] % MOD);
  return 0;
}
