#include <bits/stdc++.h>
using namespace std;
using ui = unsigned long long;
using ii = long long;
long long INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
int MOD = 1000000007;
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
  for (int i = 0; i < t.size(); ++i) {
    s << t[i] << " ";
  }
  return s;
}
class StaticInit {
  static int foo;
};
int static_init_function() {
  ios_base::sync_with_stdio(0);
  return 0;
}
int StaticInit::foo = static_init_function();
vector<vector<int>> edges;
vector<bool> colors;
pair<ui, ui> dfs(ui v) {
  pair<ui, ui> res = {!colors[v], colors[v]};
  if (!edges[v].size()) return res;
  for (ui i = 0; i < edges[v].size(); ++i) {
    pair<ui, ui> nres;
    pair<ui, ui> subtree = dfs(edges[v][i]);
    nres.first = (nres.first + res.first * subtree.second % MOD) % MOD;
    nres.first = (nres.first + res.first * subtree.first % MOD) % MOD;
    nres.second = (nres.second + res.second * subtree.second % MOD) % MOD;
    nres.second = (nres.second + res.first * subtree.second % MOD) % MOD;
    nres.second = (nres.second + res.second * subtree.first % MOD) % MOD;
    res = nres;
  }
  return res;
}
int main() {
  ui n;
  cin >> n;
  edges.resize(n);
  colors.resize(n);
  for (ui i = 1; i < n; ++i) {
    ui temp;
    cin >> temp;
    edges[temp].push_back(i);
  }
  for (ui i = 0; i < n; ++i) {
    bool temp;
    cin >> temp;
    colors[i] = temp;
  }
  cout << dfs(0).second << endl;
}
