#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 1;
const long long int mod = 1e9 + 7;
vector<vector<long long int>> graph(N);
vector<long long int> color(N);
vector<long long int> white(N, 0), black(N, 0);
void dfs1(long long int node, long long int parent) {
  white[node] = (!color[node]);
  black[node] = color[node];
  for (auto i : graph[node]) {
    if (i == parent) continue;
    dfs1(i, node);
    long long int zero = white[i];
    long long int one = black[i];
    black[node] = ((black[node] * zero) % mod + (black[node] * one) % mod +
                   (white[node] * one) % mod) %
                  mod;
    white[node] =
        ((white[node] * zero) % mod + (white[node] * one) % mod) % mod;
  }
}
int main() {
  long long int n;
  cin >> n;
  for (long long int i = 1; i < n; i++) {
    long long int a;
    cin >> a;
    graph[i].push_back(a);
    graph[a].push_back(i);
  }
  for (long long int i = 0; i < n; cin >> color[i++])
    ;
  dfs1(0, 0);
  cout << black[0] << endl;
  return 0;
}
