#include <bits/stdc++.h>
using namespace std;
vector<int> g[100010];
long long dp[100010][2];
long long num = 1e9 + 7;
int col[100010];
void dfs(int cur, int par) {
  dp[cur][col[cur]] = 1;
  for (int i = 0; i < g[cur].size(); i++) {
    if (g[cur][i] != par) {
      dfs(g[cur][i], cur);
      dp[cur][1] = (dp[cur][1] * (dp[g[cur][i]][0] + dp[g[cur][i]][1]) % num +
                    (dp[cur][0] * dp[g[cur][i]][1]) % num) %
                   num;
      dp[cur][0] = (dp[cur][0] * (dp[g[cur][i]][0] + dp[g[cur][i]][1])) % num;
    }
  }
}
int main() {
  int n, t;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d", &t);
    g[i].push_back(t);
    g[t].push_back(i);
  }
  for (int i = 0; i < n; i++) scanf("%d", &col[i]);
  dfs(0, -1);
  printf("%I64d\n", dp[0][1]);
}
