#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 100 + 3;
const long long MOD = 1000000007;
int n;
bool x[maxn];
vector<int> e[maxn];
long long dp[maxn][2];
void dfs(int source) {
  dp[source][0] = 1ll;
  dp[source][1] = 0ll;
  for (int i = 0; i < e[source].size(); i++) {
    int u = e[source][i];
    dfs(u);
    dp[source][1] = (dp[source][1] * dp[u][0]) % MOD;
    dp[source][1] = (dp[source][1] + ((dp[source][0] * dp[u][1]) % MOD)) % MOD;
    dp[source][0] = (dp[source][0] * dp[u][0]) % MOD;
  }
  if (x[source])
    dp[source][1] = dp[source][0];
  else
    dp[source][0] = (dp[source][0] + dp[source][1]) % MOD;
}
int main() {
  int an;
  cin >> n;
  for (int i = 1; i < n; i++) cin >> an, e[an].push_back(i);
  for (int i = 0; i < n; i++) cin >> x[i];
  dfs(0);
  cout << dp[0][1] << endl;
  return 0;
}
