#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1000000007;
long long dp[maxn][2];
int x[maxn];
int n;
vector<int> G[maxn];
void DP(int u) {
  dp[u][x[u]] = 1;
  for (int i = 0; i < G[u].size(); i++) {
    int son = G[u][i];
    DP(son);
    dp[u][1] = (dp[u][1] * dp[son][1] % mod + dp[u][0] * dp[son][1] % mod +
                dp[u][1] * dp[son][0] % mod) %
               mod;
    dp[u][0] =
        (dp[u][0] * dp[son][1] % mod + dp[u][0] * dp[son][0] % mod) % mod;
  }
}
int main() {
  for (int i = 0; i < maxn; i++) {
    G[i].clear();
  }
  memset(dp, 0, sizeof(dp));
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int p;
    scanf("%d", &p);
    G[p].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }
  DP(0);
  printf("%lld\n", dp[0][1]);
}
