#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long dp[100004][2];
int n;
vector<int> g[100004];
int v[100004];
void dfs(int x) {
  dp[x][v[x]] = 1;
  for (int i = 0; i < g[x].size(); i++) {
    int y = g[x][i];
    dfs(y);
    dp[x][1] = dp[x][1] * (dp[y][0] + dp[y][1]) % MOD;
    dp[x][1] = (dp[x][1] + dp[y][1] * dp[x][0]) % MOD;
    dp[x][0] = dp[x][0] * (dp[y][0] + dp[y][1]) % MOD;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x;
    scanf("%d", &x);
    g[x].push_back(i);
  }
  for (int i = 0; i < n; i++) scanf("%d", &v[i]);
  dfs(0);
  cout << dp[0][1];
}
