#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> graph[100000];
vector<bool> vertices(100000);
long long dp[100000][2];
void dfs(int v) {
  dp[v][0] = 1;
  dp[v][1] = 0;
  for (unsigned int i = 0; i < graph[v].size(); i++) {
    dfs(graph[v][i]);
    dp[v][1] *= dp[graph[v][i]][0];
    dp[v][1] %= 1000000007;
    dp[v][1] += (dp[v][0] * dp[graph[v][i]][1]);
    dp[v][1] %= 1000000007;
    dp[v][0] *= dp[graph[v][i]][0];
    dp[v][0] %= 1000000007;
  }
  if (vertices[v])
    dp[v][1] = dp[v][0];
  else {
    dp[v][0] += dp[v][1];
    dp[v][0] %= 1000000007;
  }
}
int main() {
  scanf("%d", &n);
  int v;
  for (int i = 0; i < (n - 1); i++) {
    scanf("%d", &v);
    graph[v].push_back(i + 1);
  }
  int color;
  for (int i = 0; i < n; i++) {
    scanf("%d", &color);
    vertices[i] = (bool)color;
  }
  dfs(0);
  printf("%lld\n", dp[0][1]);
  return 0;
}
