#include <bits/stdc++.h>
using namespace std;
vector<int> G[100005];
int c[100005], vis[100005];
long long dp[100005][2];
void dfs(int p) {
  vis[p] = 1;
  dp[p][c[p]] = 1;
  for (int i = 0; i < G[p].size(); i++) {
    int v = G[p][i];
    if (!vis[v]) {
      dfs(v);
      dp[p][1] =
          (dp[p][0] * dp[v][1] % 1000000007 + dp[p][1] * dp[v][0] % 1000000007 +
           dp[p][1] * dp[v][1] % 1000000007) %
          1000000007;
      dp[p][0] = (dp[p][0] * dp[v][0] % 1000000007 +
                  dp[p][0] * dp[v][1] % 1000000007) %
                 1000000007;
    }
  }
}
int main() {
  int n;
  int i, j;
  int x;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d", &x);
    G[i].push_back(x);
    G[x].push_back(i);
  }
  for (i = 0; i < n; i++) {
    scanf("%d", &c[i]);
  }
  memset(dp, 0, sizeof(dp));
  memset(vis, 0, sizeof(vis));
  dfs(0);
  printf("%I64d\n", dp[0][1]);
  return 0;
}
