#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, P = 1000000007;
long long n;
vector<long long> adj[N];
long long c[N], l[N], r[N];
int mul(long long a, long long b) { return (a * b) % P; }
int sum(long long a, long long b) { return (a + b) % P; }
pair<long long, long long> dfs(long long u, long long p) {
  vector<long long> a, b;
  for (auto x : adj[u]) {
    if (x != p) {
      auto k = dfs(x, u);
      a.push_back(k.first);
      b.push_back(k.second);
    } else {
      a.push_back(1);
      b.push_back(1);
    }
  }
  if (a.size() == 0) {
    if (c[u] == 0) {
      return {0, 1};
    } else {
      return {1, 1};
    }
  }
  if (c[u] == 0) {
    int k = adj[u].size();
    l[0] = 1;
    r[k - 1] = 1;
    for (int i = 1; i < k; i++) l[i] = mul(l[i - 1], b[i - 1]);
    for (int i = k - 2; i >= 0; i--) r[i] = mul(r[i + 1], b[i + 1]);
    long long ans = 0;
    for (int i = 0; i < k; i++)
      if (adj[u][i] != p) {
        long long res = mul(mul(l[i], r[i]), a[i]);
        ans = sum(ans, res);
      }
    long long ans2 = sum(ans, mul(l[k - 1], b[k - 1]));
    return {ans, ans2};
  } else {
    long long ans = 1;
    for (auto x : b) ans = mul(ans, x);
    return {ans, ans};
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    long long a;
    cin >> a;
    adj[a].push_back(i + 1);
    adj[i + 1].push_back(a);
  }
  for (int i = 0; i < n; i++) cin >> c[i];
  cout << dfs(0, 0).first;
}
