#include <bits/stdc++.h>
using namespace std;
const int MO = 1000000007;
int n, dp[200000][2], t;
vector<int> e[200000];
void dfs(int x) {
  for (int i = 0; i < e[x].size(); i++) {
    int t = e[x][i];
    dfs(t);
    dp[x][1] =
        ((long long)dp[x][0] * dp[t][1] + (long long)dp[x][1] * dp[t][0] +
         (long long)dp[x][1] * dp[t][1]) %
        MO;
    dp[x][0] =
        ((long long)dp[x][0] * dp[t][1] + (long long)dp[x][0] * dp[t][0]) % MO;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &t);
    e[t].push_back(i + 1);
  }
  dfs(0);
  for (int i = 0; i < n; i++) {
    scanf("%d", &t);
    if (t) {
      dp[i][0] = 0;
      dp[i][1] = 1;
    } else {
      dp[i][0] = 1;
      dp[i][1] = 0;
    }
  }
  dfs(0);
  printf("%d\n", dp[0][1]);
  return 0;
}
