#include <bits/stdc++.h>
using namespace std;
long long const INF = 1000000007;
long long mod = 1e9 + 7;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  if (b == 0) return a;
  return gcd(b, a % b);
}
struct hash_pair {
  template <class T1, class T2>
  size_t operator()(const pair<T1, T2>& p) const {
    auto hash1 = hash<T1>{}(p.first);
    auto hash2 = hash<T2>{}(p.second);
    return hash1 ^ hash2;
  }
};
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
bool isPerfectSquare(long double x) {
  if (x >= 0) {
    long long sr = sqrt(x);
    return (sr * sr == x);
  }
  return false;
}
long long fast_pow(long long a, long long p) {
  long long res = 1;
  while (p) {
    if (p % 2 == 0) {
      a = (a * a) % mod;
      p /= 2;
    } else {
      res = (res * a) % mod;
      p--;
    }
  }
  return res;
}
long long col[100005];
vector<long long> adj[100005];
long long dp[100005][2];
vector<long long> v;
void dfs(long long node, long long par) {
  dp[node][0] = 1 - col[node];
  dp[node][1] = col[node];
  for (auto child : adj[node]) {
    if (child == par) continue;
    dfs(child, node);
    long long root_one = dp[node][1], root_zero = dp[node][0];
    dp[node][1] = 0;
    dp[node][0] = 0;
    dp[node][1] += root_one * dp[child][1];
    dp[node][0] += root_zero * dp[child][1];
    dp[node][1] %= mod;
    dp[node][0] %= mod;
    dp[node][1] += (root_one * dp[child][0]) + (root_zero * dp[child][1]);
    dp[node][0] += root_zero * dp[child][0];
    dp[node][1] %= mod;
    dp[node][0] %= mod;
  }
}
void test() {
  long long n, i;
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    long long val;
    cin >> val;
    adj[val].push_back(i + 1);
    adj[i + 1].push_back(val);
  }
  for (i = 0; i < n; i++) cin >> col[i];
  dfs(0, -1);
  cout << dp[0][1] << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  long long i = 1;
  while (t--) {
    test();
    i++;
  }
  return 0;
}
