#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
const long long mod = 1000000007;
int n;
long long dp[N], clr[N];
int col[N];
struct Edge {
  int v, next;
} es[N * 2];
int head[N], cnt;
long long tot[N];
inline void add_edge(int u, int v) {
  es[cnt].v = v;
  es[cnt].next = head[u];
  head[u] = cnt++;
  es[cnt].v = u;
  es[cnt].next = head[v];
  head[v] = cnt++;
}
void dfs(int u, int fa) {
  if (col[u]) {
    dp[u] = 1;
    clr[u] = 0;
    tot[u] = 1;
  } else
    dp[u] = 0, clr[u] = 1, tot[u] = 0;
  for (int i = head[u]; ~i; i = es[i].next) {
    int v = es[i].v;
    if (v == fa) continue;
    dfs(v, u);
    if (col[u]) {
      dp[u] = dp[u] * (dp[v] + clr[v]) % mod;
      clr[u] = 0;
    } else {
      dp[u] = (dp[u] * (dp[v] + clr[v]) + clr[u] * dp[v]) % mod;
      clr[u] = clr[u] * (dp[v] + clr[v]) % mod;
    }
  }
}
int main() {
  memset(head, -1, sizeof(head));
  cin >> n;
  int v;
  for (int u = 0; u < n - 1; u++) cin >> v, add_edge(u + 1, v);
  for (int i = 0; i < n; i++) cin >> col[i];
  dfs(0, -1);
  cout << dp[0] << endl;
}
