#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T _sq(T a) {
  return a * a;
}
template <class T>
inline T _sqrt(T a) {
  return (T)sqrt((double)a);
}
template <class T, class X>
inline T _pow(T a, X y) {
  T z = 1;
  for (int i = 1; i <= y; i++) {
    z *= a;
  }
  return z;
}
template <class T>
inline T _gcd(T a, T b) {
  a = abs(a);
  b = abs(b);
  if (!b) return a;
  return _gcd(b, a % b);
}
template <class T>
inline T _lcm(T a, T b) {
  a = abs(a);
  b = abs(b);
  return (a / _gcd(a, b)) * b;
}
template <class T>
inline T _extended(T a, T b, T &x, T &y) {
  a = abs(a);
  b = abs(b);
  T g, x1, y1;
  if (!b) {
    x = 1;
    y = 0;
    g = a;
    return g;
  }
  g = _extended(b, a % b, x1, y1);
  x = y1;
  y = x1 - (a / b) * y1;
  return g;
}
template <class T, class X>
inline bool getbit(T a, X i) {
  T t = 1;
  return ((a & (t << i)) > 0);
}
template <class T, class X>
inline T setbit(T a, X i) {
  T t = 1;
  return (a | (t << i));
}
template <class T, class X>
inline T resetbit(T a, X i) {
  T t = 1;
  return (a & (~(t << i)));
}
template <class T, class X>
inline T togglebit(T a, X i) {
  T t = 1;
  return (a ^ (t << i));
}
template <class T>
void pv(T v) {
  for (int i = 0; i < ((int)v.size()); i++) cout << v[i] << " ";
  cout << endl;
}
template <class T, class X>
inline T _bigmod(T n, X m) {
  unsigned long long ret = 1, a = n % 1000000007;
  while (m) {
    if (m & 1) ret = (ret * a) % 1000000007;
    m >>= 1;
    a = (a * a) % 1000000007;
  }
  ret %= 1000000007;
  return (T)ret;
}
template <class T>
inline T _modinv(T n) {
  return _bigmod(n, 1000000007 - 2);
}
int col[(100000 + 3)];
vector<int> adj[(100000 + 3)], edge[(100000 + 3)];
bool vis[(100000 + 3)];
void dfs(int u, int p) {
  vis[u] = 1;
  adj[p].push_back(u);
  for (int i = 0; i < ((int)edge[u].size()); i++) {
    if (!vis[edge[u][i]]) {
      dfs(edge[u][i], u);
    }
  }
  return;
}
long long dp[(100000 + 3)][2];
long long go(int n, int p, int b) {
  if (p >= ((int)adj[n].size())) return !b;
  long long &ret = dp[adj[n][p]][b];
  if (ret != -1) return ret;
  ret = 0;
  if (!col[adj[n][p]]) {
    if (b) {
      ret = (ret + go(n, p + 1, 1) * go(adj[n][p], 0, 0)) % 1000000007;
      ret = (ret + go(n, p + 1, 0) * go(adj[n][p], 0, 1)) % 1000000007;
      ret = (ret + go(n, p + 1, 1) * go(adj[n][p], 0, 1)) % 1000000007;
    } else {
      ret = (ret + go(n, p + 1, 0) * go(adj[n][p], 0, 0)) % 1000000007;
      ret = (ret + go(n, p + 1, 0) * go(adj[n][p], 0, 1)) % 1000000007;
    }
  } else {
    if (b) {
      ret = (ret + go(n, p + 1, 0) * go(adj[n][p], 0, 0)) % 1000000007;
      ret = (ret + go(n, p + 1, 1) * go(adj[n][p], 0, 0)) % 1000000007;
    } else {
      ret = (ret + go(n, p + 1, 0) * go(adj[n][p], 0, 0)) % 1000000007;
    }
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i <= n - 2; i++) {
    int x;
    cin >> x;
    edge[i + 1 + 1].push_back(x + 1);
    edge[x + 1].push_back(i + 1 + 1);
  }
  for (int i = 1; i <= n; i++) {
    cin >> col[i];
  }
  vis[0] = 1;
  dfs(1, 0);
  memset(dp, -1, sizeof dp);
  cout << go(0, 0, 1) % 1000000007 << endl;
  return 0;
}
