#include <bits/stdc++.h>
using namespace std;
template <class T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
template <class T>
T min(T a, T b, T c) {
  return min(a, min(b, c));
}
const double PI = 2.0 * acos(0.0);
const int mx[] = {0, 1, 0, -1};
const int my[] = {-1, 0, 1, 0};
vector<int> E[100005];
int color[100005];
long long DP[100005][2];
bool V[100005];
void DFS(int u, int parent) {
  DP[u][color[u]] = 1;
  for (int i = 0; i < E[u].size(); i++) {
    int v = E[u][i];
    if (parent == v) continue;
    DFS(v, u);
    int t0 = DP[u][0], t1 = DP[u][1];
    DP[u][0] = t0 * (DP[v][0] + DP[v][1]) % 1000000007;
    DP[u][1] = (t0 * DP[v][1] + t1 * (DP[v][0] + DP[v][1])) % 1000000007;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int v;
    scanf("%d", &v);
    E[i].push_back(v);
    E[v].push_back(i);
  }
  for (int i = 0; i < n; i++) scanf("%d", color + i);
  DFS(0, -1);
  printf("%lld\n", DP[0][1] % 1000000007);
  return 0;
}
