#include <bits/stdc++.h>
using namespace std;
vector<int> g[100010];
long long dp[100010][3];
int black[100010];
int n;
long long mod(long long x) {
  return (x % 1000000007 + 1000000007) % 1000000007;
}
long long sum(long long a, long long b) { return mod(mod(a) + mod(b)); }
long long prod(long long a, long long b) { return mod(mod(a) * mod(b)); }
void calc(int x = 0, int p = -1) {
  dp[x][0] = 1LL;
  dp[x][1] = 0LL;
  for (int i = 0; i < g[x].size(); i++) {
    int u = g[x][i];
    if (p == u) continue;
    calc(u, x);
    dp[x][1] = prod(dp[x][1], dp[u][0]);
    dp[x][1] = sum(dp[x][1], prod(dp[x][0], dp[u][1]));
    dp[x][0] = prod(dp[x][0], dp[u][0]);
  }
  if (black[x])
    dp[x][1] = dp[x][0];
  else
    dp[x][0] = sum(dp[x][0], dp[x][1]);
}
int main() {
  int x;
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; i++) g[i].clear();
    for (int i = 0; i < n - 1; i++) {
      scanf("%d", &x);
      g[i + 1].push_back(x);
      g[x].push_back(i + 1);
    }
    for (int i = 0; i < n; i++) scanf("%d", &black[i]);
    calc();
    cout << dp[0][1] << endl;
  }
  return 0;
}
