#include <bits/stdc++.h>
using namespace std;
class disjointSet {
  int *parent;
  int *rank;
  int cs, ms;

 public:
  disjointSet(int ms = int(1e5 + 5)) {
    this->ms = ms;
    cs = 0;
    parent = new int[ms];
    rank = new int[ms];
  }
  void MakeSet(int x) {
    if (cs == ms) return;
    parent[x] = x;
    rank[x] = 0;
    cs++;
  }
  int Find(int x) {
    if (parent[x] != x) parent[x] = Find(parent[x]);
    return parent[x];
  }
  void Union(int x, int y) {
    int px = Find(x);
    int py = Find(y);
    if (px == py) return;
    if (rank[px] > rank[py])
      parent[py] = px;
    else {
      parent[px] = py;
      if (rank[px] == rank[py]) rank[py]++;
    }
  }
};
int n;
vector<vector<int> > g;
bitset<int(int(1e5 + 5))> color;
long long dp[int(1e5 + 5)][2];
void dfs(int u) {
  dp[u][0] = 1;
  dp[u][1] = 0;
  for (int v : g[u]) {
    dfs(v);
    dp[u][1] = ((dp[u][1] * dp[v][0]) % int(1e9 + 7) +
                (dp[u][0] * dp[v][1]) % int(1e9 + 7)) %
               int(1e9 + 7);
    dp[u][0] = (dp[u][0] * dp[v][0]) % int(1e9 + 7);
  }
  if (color[u])
    dp[u][1] = dp[u][0];
  else
    dp[u][0] = (dp[u][0] + dp[u][1]) % int(1e9 + 7);
}
void solve() {
  dfs(0);
  cout << dp[0][1] << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int u;
  g.assign(n, vector<int>());
  for (int v = 1; v < n; v++) {
    cin >> u;
    g[u].push_back(v);
  }
  for (int u = 0; u < n; u++) {
    int c;
    cin >> c;
    color[u] = c;
  }
  solve();
}
