#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;
long long fast_pow(long long a, long long b) {
  long long res = 1, p = a;
  while (b) {
    if (b & 1) (res *= p) %= MOD;
    b >>= 1;
    (p *= p) %= MOD;
  }
  return res;
}
vector<int> V[N];
pair<int, int> val[N];
bool has[N];
void dfs(int No, int par) {
  long long s1 = 1, s2 = 0;
  int chi = 0;
  for (auto k : V[No]) {
    if (k == par) continue;
    dfs(k, No);
    if (val[k].first != -1) {
      (s1 *= val[k].first) %= MOD;
      chi++;
    }
  }
  for (auto k : V[No]) {
    if (k == par) continue;
    if (val[k].first != -1) {
      (s2 += (s1 * fast_pow(val[k].first, MOD - 2)) % MOD * val[k].second %
             MOD) %= MOD;
    }
  }
  if (chi == 0) {
    val[No] = {1, 1};
    if (!has[No]) val[No].first = -1;
    return;
  }
  if (has[No])
    val[No] = {s1, s1};
  else
    val[No] = {s1 + s2, s2};
}
int main() {
  int n, x;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &x);
    V[i + 1].push_back(x);
    V[x].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) scanf("%d", &has[i]);
  dfs(0, -1);
  cout << val[0].second << '\n';
}
