#include <bits/stdc++.h>
using namespace std;
const double inf = 0x3f3f3f3f3f3f;
const int maxn = 1e5 + 105;
const int mod = 1e9 + 7;
int a[maxn];
std::vector<int> vv[maxn];
long long dp[maxn][2];
void dfs(int x) {
  dp[x][a[x]] = 1;
  dp[x][a[x] ^ 1] = 0;
  for (int i = 0; i < vv[x].size(); i++) {
    int v = vv[x][i];
    dfs(v);
    dp[x][1] =
        dp[x][1] * (dp[v][0] + dp[v][1]) % mod + dp[x][0] * dp[v][1] % mod;
    dp[x][1] %= mod;
    dp[x][0] = dp[x][0] * (dp[v][0] + dp[v][1]) % mod;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int p;
    scanf("%d", &p);
    p++;
    vv[p].push_back(i);
  }
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  dfs(1);
  printf("%lld\n", dp[1][1] % mod);
}
