#include <bits/stdc++.h>
using namespace std;
vector<long long int> v[100005];
long long int c[100005];
long long int ans[100005][2];
void dfs(long long int s, long long int pa = -1) {
  ans[s][0] = 1;
  ans[s][1] = 0;
  for (auto i : v[s]) {
    if (i == pa) continue;
    dfs(i, s);
    ans[s][1] *= ans[i][0];
    ans[s][1] %= 1000000007;
    ans[s][1] += (ans[s][0] * ans[i][1]) % 1000000007;
    ans[s][1] %= 1000000007;
    ans[s][0] *= ans[i][0];
    ans[s][0] %= 1000000007;
  }
  if (c[s] == 1)
    ans[s][1] = ans[s][0];
  else {
    ans[s][0] += ans[s][1];
    ans[s][0] %= 1000000007;
  }
}
int main() {
  long long int i, j, k, n, m, t;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> k;
    v[i].push_back(k);
    v[k].push_back(i);
  }
  for (i = 0; i < n; i++) {
    cin >> c[i];
  }
  dfs(0);
  cout << ans[0][1];
  return 0;
}
