#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int N;
vector<int> adj[100100];
bool black[100100];
ll dp[100100][2];
void r(int node, int par) {
  for (int i : adj[node])
    if (i != par) r(i, node);
  ll first = 1;
  for (int i : adj[node])
    if (i != par) {
      first = (first * (dp[i][0] + dp[i][1])) % (ll)(1e9 + 7);
    }
  if (black[node]) {
    ;
    dp[node][1] = first;
    return;
  }
  dp[node][0] = first;
  ll temp[2][2];
  temp[1][0] = 1, temp[1][1] = 0;
  bool childind = 0;
  for (int i : adj[node])
    if (i != par) {
      temp[childind][0] =
          (temp[!childind][0] * (dp[i][0] + dp[i][1])) % (ll)(1e9 + 7);
      temp[childind][1] = (temp[!childind][0] * dp[i][1] +
                           temp[!childind][1] * (dp[i][0] + dp[i][1])) %
                          (ll)(1e9 + 7);
      childind = !childind;
    }
  childind = !childind;
  assert(temp[childind][0] == first);
  dp[node][1] = temp[childind][1];
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i < N; i++) {
    int A;
    scanf("%d", &A);
    adj[A].push_back(i);
    adj[i].push_back(A);
  }
  for (int i = 0; i < N; i++) {
    int A;
    scanf("%d", &A);
    black[i] = A;
  }
  r(0, -1);
  printf("%d\n", dp[0][1]);
  for (int i = 0; i < N; i++) {
    ;
  }
}
