#include <bits/stdc++.h>
using namespace std;
int modInverse(int a, int m) {
  int m0 = m;
  int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    int q = a / m;
    int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
int x[100005];
vector<int> e[100005];
int pr[100005];
bool lf[100005];
void dfs(int node, int par) {
  pr[node] = par;
  bool p = false;
  for (int i : e[node]) {
    if (i != par) {
      p = true;
      dfs(i, node);
      pr[i] = node;
    }
  }
  if (!p) lf[node] = 1;
}
long long dp[100005][2];
long long run(int node, bool al) {
  if (dp[node][al] != -1) return dp[node][al];
  if (lf[node]) {
    if (al)
      return !x[node];
    else
      return 1LL * x[node];
  }
  if (x[node]) {
    if (al) {
      return dp[node][al] = 0;
    } else {
      long long ans = 1;
      for (auto u : e[node]) {
        if (u != pr[node]) {
          ans = (ans * (run(u, 1) + run(u, 0))) % 1000000007;
        }
      }
      return dp[node][al] = ans;
    }
  } else {
    if (al) {
      long long ans = 1;
      for (auto u : e[node]) {
        if (u != pr[node]) {
          ans = (ans * (run(u, 1) + run(u, 0))) % 1000000007;
        }
      }
      return dp[node][al] = ans;
    } else {
      long long all = 1, p = 0, q;
      for (auto u : e[node]) {
        if (u != pr[node]) {
          p++;
          q = u;
          all *= run(u, 1) + run(u, 0);
          all %= 1000000007;
        }
      }
      long long ans = 0;
      for (auto u : e[node]) {
        if (u != pr[node]) {
          long long temp = all;
          temp = (temp * modInverse(run(u, 1) + run(u, 0), 1000000007)) %
                 1000000007;
          temp = (temp * run(u, 0)) % 1000000007;
          ans += temp;
          ans %= 1000000007;
        }
      }
      return dp[node][al] = ans;
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int p;
    cin >> p;
    e[p].push_back(i + 1);
    e[i + 1].push_back(p);
  }
  int rr = -1;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    if (x[i] == 1) rr = i;
  }
  if (rr == -1) {
    cout << 0;
    return 0;
  }
  memset(dp, -1, sizeof dp);
  dfs(rr, -1);
  long long ans = run(rr, 0);
  cout << ans;
}
