#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int MOD = 1000000007;
vector<int> gra[MAXN];
long long dp[MAXN][2];
int mark[MAXN], n;
inline int read() {
  char ch = getchar();
  int res = 0;
  while (ch >= '0' && ch <= '9') {
    res = res * 10 + (ch - '0');
    ch = getchar();
  }
  return res;
}
void dfs(int u) {
  if (mark[u] == 1)
    dp[u][1] = 1, dp[u][0] = 0;
  else
    dp[u][1] = 0, dp[u][0] = 1;
  for (int i = 0; i < gra[u].size(); i++) {
    int v = gra[u][i];
    dfs(v);
    dp[u][1] = (dp[u][1] * (dp[v][1] + dp[v][0]) + dp[u][0] * dp[v][1]) % MOD;
    dp[u][0] = (dp[u][0] * dp[v][0] + dp[u][0] * dp[v][1]) % MOD;
  }
}
int main() {
  n = read();
  int tmp;
  for (int i = 0; i < n - 1; i++) {
    tmp = read();
    gra[tmp].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) {
    tmp = read();
    mark[i] = tmp;
  }
  dfs(0);
  cout << dp[0][1] << endl;
  return 0;
}
