#include <bits/stdc++.h>
const int MAXN = 100000;
const int MAXM = 200000;
const int MOD = 1e9 + 7;
using namespace std;
inline void enableFileIO() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}
inline int read() {
  int x = 0, w = 1;
  char c = ' ';
  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return x * w;
}
int tot, head[MAXN + 5], x[MAXN + 5], n;
long long dp[MAXN + 5][2];
struct Edge {
  int to, nxt;
  Edge() {}
  Edge(int _to, int _nxt) : to(_to), nxt(_nxt) {}
} edge[MAXM + 5];
inline void add(int u, int v) {
  edge[tot] = Edge(v, head[u]);
  head[u] = tot++;
  edge[tot] = Edge(u, head[v]);
  head[v] = tot++;
}
void init() {
  tot = 0;
  memset(head, -1, sizeof(head));
  n = read();
  for (int i = 2; i <= n; ++i) {
    int p = read();
    add(i, p + 1);
  }
  for (int i = 1; i <= n; ++i) x[i] = read();
}
void dfs(int u, int fa) {
  dp[u][x[u]] = 1;
  for (int i = head[u]; ~i; i = edge[i].nxt) {
    int v = edge[i].to;
    if (v == fa) continue;
    dfs(v, u);
    if (x[u]) {
      dp[u][1] = dp[u][1] * (dp[v][0] + dp[v][1]) % MOD;
    } else {
      dp[u][1] = (dp[u][1] * (dp[v][0] + dp[v][1]) + dp[u][0] * dp[v][1]) % MOD;
      dp[u][0] = dp[u][0] * (dp[v][0] + dp[v][1]) % MOD;
    }
  }
}
int main() {
  init();
  dfs(1, 0);
  printf("%I64d\n", dp[1][1]);
  return 0;
}
