#include <bits/stdc++.h>
using namespace std;
const long long mXn = 1e5 + 10, M = 1e9 + 7;
vector<long long> ad[mXn];
bool b[mXn], mark[mXn];
long long dp0[mXn], dp1[mXn];
void dfs(long long v) {
  if (b[v]) {
    dp1[v] = 1;
  } else {
    dp0[v] = 1;
  }
  mark[v] = true;
  for (long long i = 0; i < (long long)ad[v].size(); i++) {
    long long u = ad[v][i];
    if (!mark[u]) {
      dfs(u);
      dp1[v] = (dp1[v] * (dp1[u] + dp0[u]) + dp0[v] * dp1[u]) % M;
      dp0[v] = (dp0[v] * (dp1[u] + dp0[u])) % M;
    }
  }
}
int32_t main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long x;
    cin >> x;
    ad[x].push_back(i + 1);
    ad[i + 1].push_back(x);
  }
  for (long long i = 0; i < n; i++) {
    long long f;
    cin >> f;
    b[i] = f;
  }
  dfs(0);
  cout << dp1[0];
  return 0;
}
