#include <bits/stdc++.h>
using namespace std;
vector<int> q[100010];
long long dp[100010][2];
int N, color[100010], x;
void dfs(int x, int y) {
  dp[x][color[x]] = 1;
  for (int i = 0; i < q[x].size(); i++) {
    int temp = q[x][i];
    if (temp == y) continue;
    dfs(temp, x);
    dp[x][1] = (dp[x][1] * dp[temp][0] % 1000000007 +
                dp[x][1] * dp[temp][1] % 1000000007 +
                dp[x][0] * dp[temp][1] % 1000000007) %
               1000000007;
    dp[x][0] = (dp[x][0] * dp[temp][0] % 1000000007 +
                dp[x][0] * dp[temp][1] % 1000000007) %
               1000000007;
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i < N; i++) {
    scanf("%d", &x);
    q[i].push_back(x);
    q[x].push_back(i);
  }
  for (int i = 0; i < N; i++) scanf("%d", &color[i]);
  dfs(0, 0);
  printf("%I64d\n", dp[0][1]);
  return 0;
}
