#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100010];
int arr[100010] = {0};
int vis[100010] = {0};
long long dp[100010][2];
void dfs(int u) {
  vis[u] = 1;
  dp[u][0] = 1 - arr[u];
  dp[u][1] = arr[u];
  vector<int>::iterator vec;
  for (vec = graph[u].begin(); vec != graph[u].end(); vec++) {
    int i = (*vec);
    if (vis[i])
      continue;
    else {
      dfs(i);
      long long zero, one;
      zero = dp[u][0];
      one = dp[u][1];
      dp[u][0] = (zero * dp[i][1]) % 1000000007;
      dp[u][1] = (one * dp[i][1]) % 1000000007;
      dp[u][0] += (zero * dp[i][0]) % 1000000007;
      dp[u][0] = dp[u][0] % 1000000007;
      dp[u][1] += (zero * dp[i][1] + one * dp[i][0]) % 1000000007;
      dp[u][1] = dp[u][1] % 1000000007;
    }
  }
}
int main() {
  int n, v;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> v;
    graph[v].push_back(i);
    graph[i].push_back(v);
  }
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  dfs(0);
  cout << dp[0][1] << endl;
}
