#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 5, mod = 1e9 + 7;
long long p[mx], dp[mx][2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x;
  cin >> n;
  for (int i = 1; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> x, dp[i][x] = 1;
  for (int i = n - 1; i > 0; i--) {
    dp[p[i]][1] =
        (dp[p[i]][1] * (dp[i][1] + dp[i][0]) + dp[p[i]][0] * dp[i][1]) % mod;
    dp[p[i]][0] = (dp[p[i]][0] * (dp[i][1] + dp[i][0])) % mod;
  }
  cout << dp[0][1] << endl;
  return 0;
}
