#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
const int mod = 1e9 + 7;
int n;
vector<int> g[N];
int x[N];
long long dp[2][N];
void dfs(int u) {
  if (x[u] == 0) {
    dp[0][u] = 1;
    dp[1][u] = 0;
  } else {
    dp[0][u] = 0;
    dp[1][u] = 1;
  }
  for (int v : g[u]) {
    dfs(v);
    long long zero = dp[0][u];
    long long one = dp[1][u];
    dp[0][u] = dp[1][u] = 0;
    dp[0][u] = (zero * dp[0][v]) % mod;
    dp[1][u] = (zero * dp[1][v] + one * dp[0][v]) % mod;
    dp[0][u] = (dp[0][u] + zero * dp[1][v]) % mod;
    dp[1][u] = (dp[1][u] + one * dp[1][v]) % mod;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    g[p].emplace_back(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  dfs(0);
  cout << dp[1][0];
  return 0;
}
