#include <bits/stdc++.h>
using vi = std::vector<long long int>;
using vvi = std::vector<vi>;
using pii = std::pair<long long int, long long int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
using namespace std;
const long long int N = 2e6 + 10;
const long long int inf = 1e18 + 10;
const long long int M = 1e9 + 7;
const long double Pi = 3.14159265;
long long int n, B[N], A[N], x, y, b, w, W[N];
vi a[N];
long long int add(long long int a, long long int b) {
  a += b;
  if (a >= M) a -= M;
  return a;
}
long long int mul(long long int a, long long int b) { return a * b % M; }
void dfs(long long int u, long long int p = -1) {
  if (A[u] == 1) B[u] = 1;
  if (A[u] == 0) W[u] = 1;
  for (long long int i : a[u])
    if (i != p) {
      dfs(i, u);
      b = B[i], w = W[i];
      long long int tb = B[u], tw = W[u];
      if (A[u] == 1) {
        tw = 0;
        tb = mul(tb, add(w, b));
      }
      if (A[u] == 0) {
        tw = mul(tw, add(w, b));
        tb = add(mul(tb, add(w, b)), mul(W[u], b));
      }
      W[u] = tw;
      B[u] = tb;
    }
}
void solve() {
  cin >> n;
  for (long long int i = 1; i <= n - 1; i++) {
    cin >> x;
    a[i].push_back(x);
    a[x].push_back(i);
  }
  for (long long int i = 0; i <= n - 1; i++) {
    cin >> A[i];
  }
  dfs(0);
  cout << B[0];
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  long long int xx = 0;
  return 0;
}
