#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> p, c, sub;
vector<vector<int> > C;
vector<long long> prod1, prod0;
long long modpow(long long a, long long p) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * a) % 1000000007;
    a = (a * a) % 1000000007;
    p /= 2;
  }
  return ans;
}
void dfs(int u) {
  long long ans = 1, sum = 0;
  for (int i = 0; i < C[u].size(); i++) {
    int v = C[u][i];
    dfs(v);
    ans = (ans * (prod1[v] + prod0[v])) % 1000000007;
  }
  for (int i = 0; i < C[u].size(); i++) {
    int v = C[u][i];
    long long temp = modpow(prod0[v] + prod1[v], 1000000007 - 2);
    temp = (ans * temp) % 1000000007;
    temp = (temp * prod1[v]) % 1000000007;
    sum = (sum + temp) % 1000000007;
  }
  if (c[u]) {
    prod0[u] = 0;
    prod1[u] = ans;
  } else {
    prod0[u] = ans;
    prod1[u] = sum;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  p.resize(n);
  p[0] = -1;
  c.resize(n);
  sub.resize(n, 0);
  C.resize(n);
  prod0.resize(n, -1);
  prod1.resize(n, -1);
  for (int i = 0; i < n - 1; i++) {
    cin >> p[i + 1];
    C[p[i + 1]].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) cin >> c[i];
  dfs(0);
  cout << prod1[0] << endl;
  return 0;
}
