#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
const long long MOD = 1000000007;
int n, p[N], x[N];
vector<int> graph[N];
long long colored[N], not_colored[N];
void dfs(int u) {
  if (x[u] == 0) {
    long long haveNone = 1;
    long long haveOne = 0;
    not_colored[u] = 1;
    for (int ed = 0; ed < (int)graph[u].size(); ed++) {
      int v = graph[u][ed];
      dfs(v);
      if (x[v] == 0) {
        haveOne = (haveOne * (not_colored[v] + colored[v]) % MOD) % MOD +
                  (haveNone * colored[v]) % MOD;
        haveOne = haveOne % MOD;
        haveNone = haveNone * ((not_colored[v] + colored[v]) % MOD) % MOD;
        haveNone = haveNone % MOD;
      } else {
        haveOne = (haveOne * colored[v]) % MOD + (haveNone * colored[v]) % MOD;
        haveOne = haveOne % MOD;
        haveNone = haveNone * ((not_colored[v] + colored[v]) % MOD) % MOD;
        haveNone = haveNone % MOD;
      }
    }
    colored[u] = haveOne;
    not_colored[u] = haveNone;
  } else {
    not_colored[u] = 0;
    colored[u] = 1;
    for (int ed = 0; ed < (int)graph[u].size(); ed++) {
      int v = graph[u][ed];
      dfs(v);
      if (x[v] == 0) {
        colored[u] = colored[u] * ((not_colored[v] + colored[v]) % MOD) % MOD;
        colored[u] = colored[u] % MOD;
      } else {
        colored[u] = colored[u] * colored[v] % MOD;
        colored[u] = colored[u] % MOD;
      }
    }
  }
}
int main(void) {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d", &p[i]);
    graph[p[i]].push_back(i);
  }
  p[0] = -1;
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  dfs(0);
  printf("%I64d\n", colored[0]);
  return 0;
}
