#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 10;
vector<int> G[MAXN];
int color[MAXN];
long long dp[MAXN][2];
void init() {
  for (int i = 0; i < MAXN; i++) {
    G[i].clear();
  }
}
long long qpow(long long x, long long k) {
  long long res = 1;
  while (k > 0) {
    if (k & 1) {
      res = (res * x) % MOD;
    }
    x = (x * x) % MOD;
    k >>= 1;
  }
  return res;
}
void DFS(int u, int pa) {
  dp[u][0] = 1;
  dp[u][1] = 0;
  long long tmp1 = 0, tmp2 = 1;
  for (int v : G[u]) {
    if (v != pa) {
      DFS(v, u);
      tmp1 = (tmp1 + (dp[v][1] * qpow(dp[v][0], MOD - 2)) % MOD) % MOD;
      tmp2 = (tmp2 * dp[v][0]) % MOD;
      dp[u][0] = (dp[u][0] * dp[v][0]) % MOD;
    }
  }
  dp[u][1] = (tmp2 * tmp1) % MOD;
  if (color[u] == 1) {
    dp[u][1] = dp[u][0];
  } else {
    dp[u][0] += dp[u][1];
  }
}
int main() {
  int n;
  while (~scanf("%d", &n)) {
    init();
    for (int i = 0; i <= n - 2; i++) {
      int u;
      scanf("%d", &u);
      G[u].push_back(i + 1);
      G[i + 1].push_back(u);
    }
    for (int i = 0; i < n; i++) {
      scanf("%d", color + i);
    }
    DFS(0, -1);
    printf("%I64d\n", dp[0][1] % MOD);
  }
  return 0;
}
