#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
struct dpi {
  long long zero;
  long long black;
};
int n;
vector<vector<int> > edges;
vector<int> colors;
vector<dpi> dp;
vector<int> was;
void recalc(int v, int parent) {
  long long last_dp = 1;
  pair<long long, long long> last = make_pair(!colors[v], colors[v]);
  pair<long long, long long> nlast;
  for (int i = 0; i < (int)edges[v].size(); ++i) {
    if (edges[v][i] != parent) {
      long long newval =
          (last_dp * (dp[edges[v][i]].zero + dp[edges[v][i]].black)) % mod;
      last_dp = newval;
      dp[v].zero = last_dp;
      nlast.first =
          (last.first * (dp[edges[v][i]].zero + dp[edges[v][i]].black)) % mod;
      nlast.second =
          (last.second * (dp[edges[v][i]].zero + dp[edges[v][i]].black)) % mod +
          (last.first * dp[edges[v][i]].black) % mod;
      nlast.second %= mod;
      last = nlast;
      dp[v].zero = last.first;
      dp[v].black = last.second;
    }
  }
}
void dfs(int v, int parent = -1) {
  bool have_son = true;
  was[v] = true;
  for (int i = 0; i < (int)edges[v].size(); ++i) {
    if ((!was[edges[v][i]]) && (edges[v][i] != parent)) {
      dfs(edges[v][i], v);
      have_son = false;
    }
  }
  if (have_son) {
    if (colors[v]) {
      dp[v].black = 1;
      dp[v].zero = 0;
    } else {
      dp[v].black = 0;
      dp[v].zero = 1;
    }
  } else {
    recalc(v, parent);
  }
}
int main() {
  cin >> n;
  edges.resize(n);
  colors.resize(n);
  dp.resize(n);
  was.resize(n);
  for (int i = 1; i < n; ++i) {
    int dest;
    cin >> dest;
    edges[i].push_back(dest);
    edges[dest].push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    cin >> colors[i];
  }
  dfs(0);
  cout << dp[0].black << "\n";
  return 0;
}
