#include <bits/stdc++.h>
using namespace std;
const int base = 1000000007;
const double pi = acos(-1);
vector<int> ad[100100];
int n, f1[100100], f0[100100], F1[100100], F0[100100], top, SR[100100],
    SL[100100];
int color[100100];
void visit(int pa, int i) {
  bool ok = 0;
  for (int j = 0; j <= (int)ad[i].size() - 1; j++)
    if (ad[i][j] != pa) {
      visit(i, ad[i][j]);
      ok = 1;
    }
  if (ok == 0) {
    if (color[i]) {
      f1[i] = 1;
      f0[i] = 0;
    } else {
      f1[i] = 0;
      f0[i] = 1;
    }
    return;
  }
  if (color[i])
    f0[i] = 0;
  else {
    f0[i] = 1;
    for (int j = 0; j <= (int)ad[i].size() - 1; j++)
      if (ad[i][j] != pa) {
        int k = ad[i][j];
        f0[i] = (long long)f0[i] * (f0[k] + f1[k]) % base;
      }
  }
  if (color[i]) {
    f1[i] = 1;
    for (int j = 0; j <= (int)ad[i].size() - 1; j++)
      if (ad[i][j] != pa) {
        int k = ad[i][j];
        f1[i] = (long long)f1[i] * (f0[k] + f1[k]) % base;
      }
  } else {
    top = 0;
    for (int j = 0; j <= (int)ad[i].size() - 1; j++)
      if (ad[i][j] != pa) {
        F1[++top] = f1[ad[i][j]];
        F0[top] = f0[ad[i][j]];
      }
    SL[0] = 1;
    for (int j = 1; j <= top; j++)
      SL[j] = (long long)SL[j - 1] * (F1[j] + F0[j]) % base;
    SR[top + 1] = 1;
    for (int j = top; j >= 1; j--)
      SR[j] = (long long)SR[j + 1] * (F1[j] + F0[j]) % base;
    f1[i] = 0;
    for (int j = 1; j <= top; j++) {
      int x = ((long long)F1[j] * SL[j - 1] % base) * SR[j + 1] % base;
      f1[i] = (f1[i] + x) % base;
    }
  }
}
void solve() {
  visit(0, 1);
  cout << f1[1];
}
int main() {
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    x++;
    ad[x].push_back(i);
    ad[i].push_back(x);
  }
  for (int i = 1; i <= n; i++) scanf("%d", &color[i]);
  solve();
  return 0;
}
