#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n;
vector<int> g[100020];
int col[100020];
long long dp[100020][2];
void dfs(int u) {
  dp[u][0] = 1;
  dp[u][1] = 0;
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    dfs(v);
    dp[u][1] = dp[u][1] * dp[v][0] % 1000000007;
    dp[u][1] = (dp[u][1] + dp[u][0] * dp[v][1]) % 1000000007;
    dp[u][0] = dp[u][0] * dp[v][0] % 1000000007;
  }
  if (col[u] == 1)
    dp[u][1] = dp[u][0];
  else
    dp[u][0] += dp[u][1];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  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 >> col[i];
  dfs(0);
  cout << dp[0][1] << endl;
  return 0;
}
