#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using pii = pair<int, int>;
const double EPS = 1e-9;
const double PI = 2 * asin(1);
const int INF = 0x3fffffff;
const LL LINF = 0x3fffffffffffffff;
const LL MOD = 1000000000 + 7;
const int MX = 100000 + 10;
int g_n;
LL dp[MX][2];
vector<bool> vb_cor;
vector<vector<int>> vvi_e;
void pretreat() {}
bool input() {
  cin >> g_n;
  if (cin.eof()) return false;
  memset(dp, 0, sizeof(dp));
  vb_cor.clear(), vvi_e.clear(), vvi_e.resize(g_n);
  for (int i = 1, t; i < g_n; ++i) {
    scanf(" %d", &t);
    vvi_e[i].push_back(t);
    vvi_e[t].push_back(i);
  }
  for (int i = 0, t; i < g_n; ++i) {
    scanf(" %d", &t);
    vb_cor.push_back(t);
  }
  return true;
}
void dfs(int u, int p) {
  if (vb_cor[u])
    dp[u][1] = 1;
  else
    dp[u][0] = 1;
  for (int i = 0; i < vvi_e[u].size(); ++i) {
    int v = vvi_e[u][i];
    if (v == p) continue;
    dfs(v, u);
    dp[u][1] = (((LL)dp[u][1] * (dp[v][0] + dp[v][1])) % MOD +
                ((LL)dp[u][0] * dp[v][1]) % MOD) %
               MOD;
    dp[u][0] = ((LL)dp[u][0] * (dp[v][0] + dp[v][1])) % MOD;
  }
}
void solve() {
  dfs(0, -1);
  cout << dp[0][1] << endl;
}
int main() {
  pretreat();
  while (input()) {
    solve();
  }
  return 0;
}
