#include <bits/stdc++.h>
using namespace std;
constexpr long long mod = 1000000007;
pair<long long, long long> dfs(int v, const vector<vector<int>> &children,
                               const vector<int> &black) {
  long long zero = 0;
  long long one = 0;
  (black[v] ? one : zero) = 1;
  for (const auto &child : children[v]) {
    const auto result = dfs(child, children, black);
    long long t_zero = (zero * result.second + zero * result.first) % mod;
    one =
        (one * result.second + zero * result.second + one * result.first) % mod;
    zero = t_zero;
  }
  return {zero, one};
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int>> children(n);
  for (int i = 1; i < n; ++i) {
    int p;
    cin >> p;
    children[p].emplace_back(i);
  }
  vector<int> black(n);
  for (auto &e : black) cin >> e;
  const auto ans = dfs(0, children, black);
  cout << ans.second << endl;
  return EXIT_SUCCESS;
}
