#include <bits/stdc++.h>
using namespace std;
vector<int> v[100010];
bool col[100010];
long long dp[100010][2];
const int mod = 1e9 + 7;
void dfs(int x) {
  int sz = v[x].size();
  dp[x][col[x]] = 1;
  for (int i = 0; i < sz; i++) {
    dfs(v[x][i]);
    dp[x][1] = (dp[x][1] * (dp[v[x][i]][0] + dp[v[x][i]][1]) % mod +
                dp[x][0] * dp[v[x][i]][1] % mod) %
               mod;
    dp[x][0] = dp[x][0] * (dp[v[x][i]][0] + dp[v[x][i]][1]) % mod;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int tmp;
    scanf("%d", &tmp);
    v[tmp].push_back(i);
  }
  for (int i = 0; i < n; i++) scanf("%d", &col[i]);
  dfs(0);
  printf("%d\n", dp[0][1]);
  return 0;
}
