#include <bits/stdc++.h>
using namespace std;
long long pow(long long a, long long b, long long m) {
  if (a == 0) return 0;
  if (b == 0) return 1;
  long long temp = pow(a, b / 2, m);
  temp = ((temp % m) * (temp % m)) % m;
  if (b & 1) temp = ((temp % m) * (a % m)) % m;
  return temp;
}
long long string_to_num(string s) {
  stringstream num(s);
  long long x;
  num >> x;
  return x;
}
string num_to_string(long long n) {
  string s;
  while (n > 0) {
    s = char(n % 10 + '0') + s;
    n /= 10;
  }
  return ((s.length() == 0) ? "0" : s);
}
const long long MOD = 998244353;
const long long mod = 1e9 + 7;
const long long N = 1e6 + 5;
long long n;
vector<long long> adj[N];
long long col[N], W[N], B[N];
void dfs(long long u, long long par = -1) {
  W[u] = 1 - col[u];
  B[u] = col[u];
  for (auto v : adj[u]) {
    if (v == par) continue;
    dfs(v, u);
    long long white_ = (W[u] * W[v]) % mod;
    long long black_ = (((B[u] * W[v]) % mod) + ((B[v] * W[u]) % mod)) % mod;
    white_ = (white_ + ((W[u] * B[v]) % mod)) % mod;
    black_ = (black_ + ((B[u] * B[v]) % mod)) % mod;
    W[u] = white_;
    B[u] = black_;
  }
}
void solve() {
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long x;
    cin >> x;
    adj[x].push_back(i + 1);
    adj[i + 1].push_back(x);
  }
  for (long long i = 0; i < n; i++) {
    cin >> col[i];
  }
  dfs(0);
  cout << B[0] << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  for (long long T = 1; T <= t; T++) {
    solve();
  }
}
