#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
vector<bool> black;
vector<long long> memblack, memwhite;
const long long mod = 1e9 + 7;
long long calcblack(int x);
long long calcwhite(int x) {
  if (black[x]) return 0;
  if (memwhite[x] != -1) return memwhite[x];
  long long res = 1;
  for (int y : g[x]) {
    res *= calcwhite(y) + calcblack(y);
    res %= mod;
  }
  memwhite[x] = res;
  return res;
}
long long calcblack(int x) {
  if (memblack[x] != -1) return memblack[x];
  if (black[x]) {
    long long res = 1;
    for (int y : g[x]) {
      res *= calcwhite(y) + calcblack(y);
      res %= mod;
    }
    memblack[x] = res;
    return res;
  }
  vector<long long> prod(g[x].size() + 1, 1);
  for (int i = g[x].size() - 1; i >= 0; i--)
    prod[i] = (prod[i + 1] * (calcwhite(g[x][i]) + calcblack(g[x][i]))) % mod;
  long long res = 0;
  long long res2 = 1;
  for (int i = 0; i < g[x].size(); i++) {
    int y = g[x][i];
    res += calcblack(y) * ((res2 * prod[i + 1]) % mod);
    res %= mod;
    res2 *= calcwhite(y) + calcblack(y);
    res2 %= mod;
  }
  memblack[x] = res;
  return res;
}
int main() {
  int n;
  cin >> n;
  g.resize(n);
  memblack = memwhite = vector<long long>(n, -1);
  for (int i = 1; i < n; i++) {
    int j;
    cin >> j;
    g[j].push_back(i);
  }
  black.resize(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    black[i] = x == 1;
  }
  cout << calcblack(0) << endl;
}
