#include <bits/stdc++.h>
using namespace std;
int n;
const int mo = 1000000007;
const int N = 200000;
long long f[N][2];
int t[N], s[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) scanf("%d", t + i + 1);
  for (int i = 0; i < n; i++) {
    scanf("%d", &s[i]);
    f[i][s[i]] = 1;
  }
  for (int i = n - 1; i > 0; i--) {
    f[t[i]][1] = (f[t[i]][1] * (f[i][0] + f[i][1]) + f[t[i]][0] * f[i][1]) % mo;
    f[t[i]][0] = (f[t[i]][0] * (f[i][0] + f[i][1])) % mo;
  }
  cout << f[0][1];
}
