#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void Cin(T &x) {
  char c;
  T sign = 1;
  x = 0;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    if (c == '-') sign = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sign;
}
const int N = 1e5 + 7;
const int mod = 1e9 + 7;
vector<int> a[N];
int x, n, chk[N];
long long f[N], c[N], g[N];
void DFS(int u) {
  chk[u] = g[u] = 1;
  f[u] = 0;
  for (int v : a[u]) {
    if (chk[v]) continue;
    DFS(v);
    f[u] = (f[u] * g[v]) % mod;
    f[u] = (f[u] + (g[u] * f[v] % mod)) % mod;
    g[u] = (g[u] * g[v]) % mod;
  }
  if (c[u])
    f[u] = g[u];
  else
    g[u] = (g[u] + f[u]) % mod;
}
void Enter() {
  cin >> n;
  for (int i = 1; i <= n - 1; ++i) cin >> x, a[x].push_back(i);
  for (int i = 0; i <= n - 1; ++i) cin >> c[i];
}
void Solve() {
  DFS(0);
  cout << f[0] % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  Enter();
  Solve();
  return 0;
}
