#include <bits/stdc++.h>
using namespace std;
long long n;
long long col[100002];
set<long long> g[100002];
long long dp[100002][2];
void initialization() {
  cin >> n;
  for (long long i = 1; i < n; ++i) {
    long long c;
    cin >> c;
    g[c].insert(i);
  }
  for (long long i = 0; i < n; ++i) cin >> col[i];
}
void dfs(long long cur) {
  if (!col[cur]) {
    dp[cur][0] = 1;
    dp[cur][1] = 0;
  }
  if (col[cur]) {
    dp[cur][0] = 0;
    dp[cur][1] = 1;
  }
  for (long long next : g[cur]) {
    dfs(next);
    if (col[cur])
      dp[cur][1] = (dp[cur][1] * dp[next][0]) % 1000000007;
    else {
      dp[cur][1] =
          (dp[cur][1] * dp[next][0] + dp[next][1] * dp[cur][0]) % 1000000007;
      dp[cur][0] = (dp[cur][0] * dp[next][0]) % 1000000007;
    }
  }
  dp[cur][0] = (dp[cur][0] + dp[cur][1]) % 1000000007;
}
void solve() { dfs(0); }
void print() { cout << dp[0][1]; }
int main() {
  initialization();
  solve();
  print();
  return 0;
}
