#include <bits/stdc++.h>
inline long long sbt(long long x) { return __builtin_popcount(x); }
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
vector<long long> adj[100013];
long long n, dp[100013][2];
bool is[100013];
void dfs(long long node, long long par) {
  dp[node][0] = !is[node];
  dp[node][1] = is[node];
  for (auto nei : adj[node]) {
    if (nei != par) {
      long long prev_curr_black = dp[node][1];
      long long prev_curr_white = dp[node][0];
      dp[node][0] = dp[node][1] = 0;
      dfs(nei, node);
      dp[node][1] = ((prev_curr_white * dp[nei][1]) % 1000000007 +
                     (prev_curr_black * dp[nei][0]) % 1000000007) %
                    1000000007;
      dp[node][0] = (dp[nei][0] * prev_curr_white) % 1000000007;
      dp[node][0] =
          (dp[node][0] + (prev_curr_white * dp[nei][1]) % 1000000007) %
          1000000007;
      dp[node][1] =
          (dp[node][1] + (prev_curr_black * dp[nei][1]) % 1000000007) %
          1000000007;
    }
  }
}
int32_t main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cin >> n;
  long long u, v;
  for (long long i = 0; i < n - 1; i++) {
    cin >> u;
    adj[(i + 1)].push_back(u);
    adj[u].push_back((i + 1));
  }
  for (long long i = 0; i < n; i++) cin >> is[i];
  dfs(0, -1);
  cout << dp[0][1];
  return 0;
}
