#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LINF = 1e17;
const double DINF = numeric_limits<double>::max();
const int ITER = 300;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const int MAXN = 1e5 + 10;
int n;
vector<int> g[MAXN];
int B[MAXN];
int dp[MAXN][2];
void mod(int v) {
  for (int i = 0; i < 2; i++) dp[v][i] %= MOD;
}
void dfs(int v) {
  dp[v][0] = 1 - B[v];
  dp[v][1] = B[v];
  for (int u : g[v]) {
    int old[2];
    old[0] = dp[v][0];
    old[1] = dp[v][1];
    dp[v][0] = dp[v][1] = 0;
    dfs(u);
    dp[v][0] += (1ll * old[0] * dp[u][1]) % MOD;
    dp[v][1] += (1ll * old[1] * dp[u][1]) % MOD;
    mod(v);
    dp[v][1] += (1ll * old[1] * dp[u][0]) % MOD;
    mod(v);
    dp[v][1] += (1ll * old[0] * dp[u][1]) % MOD;
    mod(v);
    dp[v][0] += (1ll * old[0] * dp[u][0]) % MOD;
    mod(v);
  }
}
void solve() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    g[p].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> B[i];
  }
  dfs(0);
  cout << dp[0][1] << endl;
}
int main() {
  cout << setprecision(12) << fixed;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
