#include <bits/stdc++.h>
using namespace std;
long long M = 1000000007;
int n;
vector<int> G[100005];
long long no[100005], one[100005];
bool black[100005];
void dfs(int u) {
  if (black[u]) {
    one[u] = 1;
    no[u] = 0;
  } else {
    one[u] = 0;
    no[u] = 1;
  }
  int sz = G[u].size();
  for (int i = 0; i < sz; i++) {
    int t = G[u][i];
    dfs(t);
    long long sum = one[t] + no[t];
    one[u] = (one[u] * sum + no[u] * one[t]) % M;
    no[u] = (sum * no[u]) % M;
  }
}
int main() {
  cin >> n;
  int t;
  for (int i = 1; i < n; i++) {
    scanf("%d", &t);
    G[t].push_back(i);
  }
  for (int i = 0; i < n; i++) scanf("%d", &black[i]);
  dfs(0);
  cout << one[0] << endl;
  return 0;
}
