#include <bits/stdc++.h>
using namespace std;
inline void err(istringstream *iss) {}
template <typename T, typename... Args>
void err(istringstream *iss, const T &$val, const Args &...args) {
  string $name;
  *iss >> $name;
  if ($name.back() == ',') $name.pop_back();
  cout << $name << " = " << $val << "; ", err(iss, args...);
}
using ll = long long;
using ull = unsigned long long;
using ld = long double;
int n, m, K, T, Q, cn;
list<int> adj[100005];
int x[100005];
ll pre[100005], dp[100005][2];
void dfs(const int &u, const int &p) {
  dp[u][0] = 1;
  for (auto &v : adj[u])
    if (v != p) {
      dfs(v, u), pre[v] = dp[u][0] * dp[v][1] % 1000000007,
                 dp[u][0] = (dp[u][0] * (dp[v][0] + dp[v][1])) % 1000000007;
    }
  ll suf = 1;
  for (auto it = adj[u].rbegin(); it != adj[u].rend();) {
    auto &v = *it;
    dp[u][1] = (dp[u][1] + pre[v] * suf) % 1000000007,
    suf = (suf * (dp[v][0] + dp[v][1])) % 1000000007;
    it++;
  }
  if (x[u]) dp[u][1] = max(1ll, dp[u][0]), dp[u][0] = 0;
  0;
}
int main() {
  cin.tie(NULL);
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &m), adj[m].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }
  dfs(0, 100005 - 1);
  printf("%lld\n", dp[0][1]);
  return 0;
}
