#include <bits/stdc++.h>
using namespace std;
vector<int> e[100007];
long long val_array[100007];
long long val_array2[100007];
int color[100007];
int borw[100007];
int count1[100007];
void count_black(int v) {
  if (color[v]) return;
  color[v] = 1;
  if (borw[v]) count1[v] = 1;
  for (int i = 0; i < e[v].size(); i++) {
    if (!color[e[v][i]]) {
      count_black(e[v][i]);
      count1[v] += count1[e[v][i]];
    }
  }
}
long long dfs(int v) {
  color[v] = 1;
  if (!borw[v]) {
    val_array[v] = 0;
    val_array2[v] = 1;
    for (int i = 0; i < e[v].size(); i++) {
      if (!color[e[v][i]]) {
        long long temp = dfs(e[v][i]);
        if (count1[e[v][i]] && val_array[v])
          val_array[v] =
              ((temp)*val_array2[v] + val_array2[e[v][i]] * val_array[v] +
               val_array[v] * val_array[e[v][i]]) %
              1000000007;
        else if ((!val_array[v]) && count1[e[v][i]])
          val_array[v] = temp % 1000000007;
        val_array2[v] = ((val_array2[v] * val_array[e[v][i]]) +
                         val_array2[v] * val_array2[e[v][i]]) %
                        1000000007;
      }
    }
  } else {
    val_array2[v] = 0;
    val_array[v] = 1;
    for (int i = 0; i < e[v].size(); i++) {
      if (!color[e[v][i]]) {
        long long temp = dfs(e[v][i]);
        if (count1[e[v][i]]) {
          val_array[v] =
              (val_array[v] * temp + val_array[v] * val_array2[e[v][i]] +
               val_array2[v] * val_array[e[v][i]]) %
              1000000007;
        }
      }
    }
  }
  return val_array[v];
}
int main() {
  int n;
  cin >> n;
  int a;
  for (int i = 1; i <= n - 1; i++) {
    cin >> a;
    e[i].push_back(a);
    e[a].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> borw[i];
  }
  count_black(0);
  memset(color, 0, sizeof(color));
  cout << dfs(0);
}
