#include <bits/stdc++.h>
using namespace std;
int p[100010];
long long d[100010][2];
int main(void) {
  int n, xi;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d", &p[i + 1]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &xi);
    d[i][xi] = 1;
  }
  for (int i = n - 1; i > 0; --i) {
    d[p[i]][1] =
        (d[p[i]][1] * (d[i][0] + d[i][1]) + d[p[i]][0] * d[i][1]) % 1000000007;
    d[p[i]][0] = (d[p[i]][0] * (d[i][0] + d[i][1])) % 1000000007;
  }
  printf("%lld\n", d[0][1]);
}
