#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const long long mod = 1e9 + 7;
int n, x;
long long a[N], d[N][2];
vector<int> g[N];
void dfs(int u, int fa) {
  d[u][a[u]] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == fa) continue;
    dfs(v, u);
    d[u][1] = (d[u][1] * d[v][0] % mod + d[u][1] * d[v][1] % mod +
               d[u][0] * d[v][1] % mod) %
              mod;
    d[u][0] = (d[u][0] * d[v][0] % mod + d[u][0] * d[v][1] % mod) % mod;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  ;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x;
    g[i].push_back(x);
    g[x].push_back(i);
  }
  for (int i = 0; i < n; i++) cin >> a[i];
  dfs(0, -1);
  cout << d[0][1] << endl;
}
