#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n; if (!(cin >> n)) return 0;
    vector<int> parent(n, -1);
    for (int i = 1; i < n; ++i) cin >> parent[i];
    vector<array<long long, 2>> dp(n);
    for (int i = 0, black; i < n; ++i) { cin >> black; dp[i][black] = 1; }
    const long long mod = 1000000007;
    // The statement guarantees parent[i] < i, so reverse index order is postorder
    for (int v = n - 1; v > 0; --v) {
        int p = parent[v];
        auto a = dp[p], b = dp[v];
        dp[p][0] = a[0] * ((b[0] + b[1]) % mod) % mod;
        dp[p][1] = (a[1] * ((b[0] + b[1]) % mod) + a[0] * b[1]) % mod;
    }
    cout << dp[0][1] << '\n';
}
