#include <bits/stdc++.h>
using namespace std;
const int N = 100300;
vector<int> g[N];
const int mod = 1e9 + 7;
long long dp[N][2];
int x[N];
int n;
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] + dp[u][0] * dp[v][1]) % mod;
    dp[u][0] = dp[u][0] * dp[v][0] % mod;
  }
  if (x[u] == 1)
    dp[u][1] = dp[u][0];
  else
    dp[u][0] = (dp[u][0] + dp[u][1]) % mod;
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int p;
    scanf("%d", &p);
    g[p].push_back(i);
  }
  for (int i = 0; i < n; i++) scanf("%d", x + i);
  dfs(0);
  long long ans = dp[0][1];
  cout << ans << endl;
}
