#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double eps = 1e-10;
const double pi = acos(-1.0);
const long long INF = 1LL << 62;
const int inf = 1 << 29;
const long long mod = 1000000007LL;
long long dp[100010][2];
vector<int> graph[100010];
bool color[100010];
long long inv(long long a) {
  long long ans = 1;
  long long b = a;
  long long n = mod - 2;
  while (n) {
    if (n & 1) ans = (ans * b) % mod;
    b = (b * b) % mod;
    n >>= 1;
  }
  return (ans + mod) % mod;
}
void dfs(int v, int p) {
  vector<int> child;
  int vn = graph[v].size();
  for (int i = (0); i < (vn); ++i) {
    int v2 = graph[v][i];
    if (graph[v][i] != p) {
      dfs(v2, v);
      child.push_back(v2);
    }
  }
  int cn = child.size();
  if (cn == 0) {
    dp[v][color[v]] = 1;
    return;
  } else {
    long long pro = 1;
    for (int i = (0); i < (cn); ++i)
      pro = (pro * (dp[child[i]][0] + dp[child[i]][1])) % mod;
    if (color[v])
      dp[v][1] = pro;
    else {
      dp[v][0] = pro;
      for (int i = (0); i < (cn); ++i) {
        long long tmp = pro * inv(dp[child[i]][0] + dp[child[i]][1]) % mod *
                        dp[child[i]][1] % mod;
        dp[v][1] = (dp[v][1] + tmp) % mod;
      }
    }
    return;
  }
}
int main(void) {
  int n;
  cin >> n;
  for (int i = (0); i < (n - 1); ++i) {
    int a, b = i + 1;
    cin >> a;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  for (int i = (0); i < (n); ++i) cin >> color[i];
  dfs(0, -1);
  cout << dp[0][1] << endl;
  return 0;
}
