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