#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > G;
vector<int> COLOR;
vector<vector<long long> > DP;
const long long mod = 1e9 + 7;
long long pow(long long n, long long p) {
  long long res = 1;
  while (p > 0) {
    if (p & 1LL) {
      res *= n;
      res %= mod;
    }
    n *= n;
    n %= mod;
    p /= 2;
  }
  return res;
}
long long inv(long long n) { return pow(n, mod - 2); }
void solve(int vId, int parentId) {
  if (G[vId].size() > 1 || vId == 0) {
    for (int i = 0; i < G[vId].size(); ++i) {
      if (parentId != G[vId][i]) solve(G[vId][i], vId);
    }
    if (COLOR[vId] == 0) {
      long long cur = 1;
      for (int i = 0; i < G[vId].size(); ++i) {
        int w = G[vId][i];
        if (w != parentId) {
          cur *= (DP[w][0] + DP[w][1]);
          assert((DP[w][0] + DP[w][1]) > 0);
          cur %= mod;
        }
      }
      DP[vId][0] = 1;
      for (int i = 0; i < G[vId].size(); ++i) {
        int w = G[vId][i];
        if (w != parentId) {
          long long now = (DP[w][1] * inv(DP[w][0] + DP[w][1])) % mod;
          DP[vId][1] += (cur * now) % mod;
          DP[vId][1] %= mod;
          DP[vId][0] = DP[vId][0] * (DP[w][0] + DP[w][1]);
          DP[vId][0] %= mod;
        }
      }
    } else {
      DP[vId][0] = 0;
      DP[vId][1] = 1;
      for (int i = 0; i < G[vId].size(); ++i) {
        int w = G[vId][i];
        if (w != parentId) DP[vId][1] = DP[vId][1] * (DP[w][0] + DP[w][1]);
        DP[vId][1] %= mod;
      }
    }
  } else {
    if (COLOR[vId] == 1) {
      DP[vId][1] = 1;
      DP[vId][0] = 0;
    } else {
      DP[vId][1] = 0;
      DP[vId][0] = 1;
    }
  }
}
int main() {
  int n;
  cin >> n;
  DP = vector<vector<long long> >(n, vector<long long>(2, 0));
  vector<vector<int> > graph(n, vector<int>());
  for (int i = 0; i < n - 1; ++i) {
    int pi;
    cin >> pi;
    graph[i + 1].push_back(pi);
    graph[pi].push_back(i + 1);
  }
  G = graph;
  vector<int> color(n);
  for (int i = 0; i < n; ++i) cin >> color[i];
  COLOR = color;
  solve(0, -1);
  cout << DP[0][1] << endl;
  return 0;
}
