#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e5 + 10;
const int mod = (int)1e9 + 7;
int p[maxn];
long long d[maxn][2];
int n, x;
int main() {
  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", &x);
    d[i][x] = 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]) % mod;
    d[p[i]][0] = (d[p[i]][0] * (d[i][0] + d[i][1])) % mod;
  }
  cout << d[0][1] << endl;
}
