#include <bits/stdc++.h>
using namespace std;
int n, col[123456];
long long dp[123456][2];
vector<int> G[123456];
void addedge(int x, int y) { G[x].push_back(y); }
void init() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int tmp;
    scanf("%d", &tmp);
    addedge(tmp, i + 1);
  }
  for (int i = 0; i < n; i++) scanf("%d", &col[i]);
}
void dfs(int v) {
  dp[v][col[v]] = 1;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    dfs(u);
    dp[v][1] =
        (dp[v][1] * dp[u][0] + dp[v][1] * dp[u][1] + dp[v][0] * dp[u][1]) %
        1000000007;
    dp[v][0] = (dp[v][0] * dp[u][0] + dp[v][0] * dp[u][1]) % 1000000007;
  }
}
void solve() {
  dfs(0);
  cout << dp[0][1] << endl;
}
int main() {
  init();
  solve();
}
