#include <bits/stdc++.h>
using namespace std;
const int sz = 200010;
vector<int> g[sz];
long long int a[sz], dp[sz][2];
void dfs(int u, int p) {
  dp[u][0] = 1;
  dp[u][1] = 0;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v != p) {
      dfs(v, u);
      dp[u][1] = (dp[u][1] * dp[v][0] % 1000000007 +
                  dp[u][0] * dp[v][1] % 1000000007) %
                 1000000007;
      dp[u][0] = dp[u][0] * dp[v][0] % 1000000007;
    }
  }
  if (a[u] == 1) {
    dp[u][1] = dp[u][0];
  } else {
    dp[u][0] += dp[u][1];
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u;
    cin >> u;
    g[i].push_back(u);
    g[u].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  dfs(1, -1);
  cout << dp[1][1] << endl;
  return 0;
}
