#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long n, dp[100005][2];
std::set<int> ch[100005];
bool c[100005];
void init(int h = 0) {
  for (std::set<int>::iterator it = ch[h].begin(); it != ch[h].end(); ++it) {
    ch[*it].erase(h);
    init(*it);
  }
}
void process(int h = 0) {
  int sz = ch[h].size();
  if (sz == 0) {
    dp[h][1] = c[h];
    dp[h][0] = !c[h];
    return;
  }
  for (std::set<int>::iterator it = ch[h].begin(); it != ch[h].end(); ++it) {
    process(*it);
  }
  dp[h][1] = c[h];
  dp[h][0] = !c[h];
  for (std::set<int>::iterator it = ch[h].begin(); it != ch[h].end(); ++it) {
    int j = *it;
    long long temp1 = dp[h][1];
    long long temp0 = dp[h][0];
    dp[h][1] = 0;
    dp[h][0] = 0;
    if (dp[j][1] > 0) {
      dp[h][1] += temp1 * dp[j][1];
      dp[h][0] += temp0 * dp[j][1];
    }
    if (dp[j][0] > 0) {
      dp[h][1] += temp1 * dp[j][0];
      dp[h][0] += temp0 * dp[j][0];
    }
    if (dp[j][1] > 0) {
      dp[h][1] += temp0 * dp[j][1];
    }
    dp[h][1] %= MOD;
    dp[h][0] %= MOD;
  }
}
int main() {
  std::cin >> n;
  for (int k = 0; k < n - 1; ++k) {
    int x;
    std::cin >> x;
    ch[x].insert(k + 1);
    ch[k + 1].insert(x);
  }
  for (int k = 0; k < n; ++k) {
    std::cin >> c[k];
  }
  init();
  process();
  std::cout << dp[0][1] << std::endl;
  return 0;
}
