#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int INF = 2e9;
const long long INFLL = 1e18;
const int MAX_N = 100000;
int N;
int p[MAX_N + 1];
int c[MAX_N + 1];
vector<int> gp[MAX_N + 1];
long long dp[MAX_N + 1][2];
long long multi(long long x, long long y) {
  if (y == 1) return x;
  long long m = multi(x, y / 2);
  if (y % 2) {
    return (((m * m) % MOD) * x) % MOD;
  } else {
    return (m * m) % MOD;
  }
}
long long inv(long long x) { return multi(x, MOD - 2); }
void dfs(int x) {
  for (int i : gp[x]) {
    dfs(i);
  }
  if (c[x] == 0) {
    dp[x][0] = 1;
    for (int i : gp[x]) {
      dp[x][0] = (dp[x][0] * dp[i][0]) % MOD;
    }
    for (int i : gp[x]) {
      dp[x][1] =
          (dp[x][1] + ((dp[x][0] * inv(dp[i][0])) % MOD * dp[i][1]) % MOD) %
          MOD;
    }
  } else {
    dp[x][0] = 0;
    dp[x][1] = 1;
    for (int i : gp[x]) {
      dp[x][1] = dp[x][1] * dp[i][0] % MOD;
    }
  }
  dp[x][0] = (dp[x][0] + dp[x][1]) % MOD;
  if (0) cout << x << " " << dp[x][0] << " " << dp[x][1] << endl;
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i < N; i++) {
    int x;
    scanf("%d", &x);
    gp[x].push_back(i);
    p[i] = x;
  }
  for (int i = 0; i < N; i++) {
    scanf("%d", &c[i]);
  }
  dfs(0);
  cout << dp[0][1];
  return 0;
}
