#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e1) {
  cout << e1 << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
int n;
bool flag[100000 + 7];
long long int dp[100000 + 7][3];
vector<int> adj[100000 + 7];
void rec(int u, int pre) {
  int v, i, j, k;
  long long int one, zero;
  dp[u][0] = flag[u] == 0;
  dp[u][1] = flag[u] == 1;
  for (i = 0; i < adj[u].size(); i++) {
    v = adj[u][i];
    if (v == pre) continue;
    zero = dp[u][0];
    one = dp[u][1];
    dp[u][0] = dp[u][1] = 0;
    rec(v, u);
    dp[u][0] = (zero * dp[v][1]) % 1000000007;
    dp[u][1] = (one * dp[v][1]) % 1000000007;
    dp[u][0] += (zero * dp[v][0]) % 1000000007;
    dp[u][0] %= 1000000007;
    dp[u][1] += (one * dp[v][0]) % 1000000007;
    dp[u][1] %= 1000000007;
    dp[u][1] += (zero * dp[v][1]) % 1000000007;
    dp[u][1] %= 1000000007;
  }
}
int main() {
  int u, c, i, j, k;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d", &u);
    adj[u].push_back(i);
    adj[i].push_back(u);
  }
  for (i = 0; i < n; i++) {
    scanf("%d", &u);
    flag[i] = u;
  }
  rec(1, -1);
  printf("%lld\n", dp[1][1]);
  return 0;
}
