#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int n, p, root;
long long dp[100010][2];
int a[100010];
vector<int> v[100010];
void dfs(int root, int fa) {
  int len, i, next;
  len = v[root].size();
  dp[root][0] = 1;
  dp[root][1] = 0;
  for (i = 0; i < len; i++) {
    if (v[root][i] == fa) continue;
    next = v[root][i];
    dfs(next, root);
    dp[root][1] = (dp[root][0] * dp[next][1] + dp[root][1] * dp[next][0]) % mod;
    dp[root][0] = (dp[root][0] * dp[next][0]) % mod;
  }
  if (a[root] == 0)
    dp[root][0] = (dp[root][1] + dp[root][0]) % mod;
  else
    dp[root][1] = dp[root][0];
}
int main() {
  int i, x;
  while (scanf("%d", &n) != EOF && n != 0) {
    memset(dp, 0, sizeof(dp));
    for (i = 1; i < n; i++) {
      scanf("%d", &x);
      v[x].push_back(i);
      v[i].push_back(x);
    }
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    dfs(0, -1);
    printf("%lld\n", dp[0][1]);
  }
  return 0;
}
