#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int MN = 100111;
long long f[2][MN];
vector<int> ke[MN];
int n, col[MN];
void init() {
  for (int i = (1), _b = (n); i <= _b; i++) ke[i].clear();
  memset(f, 0, sizeof f);
}
void dfs(int u) {
  if (ke[u].size() == 0) {
    if (col[u] == 0) {
      f[0][u] = 1;
      f[1][u] = 0;
    } else {
      f[0][u] = 0;
      f[1][u] = 1;
    }
    return;
  }
  vector<long long> f0;
  vector<long long> f1;
  vector<long long> left, right;
  int k = ke[u].size();
  f0.resize(k);
  f1.resize(k);
  left.resize(k);
  right.resize(k);
  for (int i = 0, _a = (k); i < _a; i++) {
    int v = ke[u][i];
    dfs(v);
    f0[i] = f[0][v];
    f1[i] = f[1][v];
  }
  for (int i = 0, _a = (k); i < _a; i++) {
    if (i == 0) {
      left[i] = (f0[i] + f1[i]) % MOD;
    } else {
      left[i] = (left[i - 1] * f0[i] + left[i - 1] * f1[i]) % MOD;
    }
  }
  for (int i = (k - 1), _b = (0); i >= _b; i--) {
    if (i == k - 1) {
      right[i] = (f0[i] + f1[i]) % MOD;
    } else {
      right[i] = (right[i + 1] * (f0[i] + f1[i])) % MOD;
    }
  }
  if (col[u] == 0) {
    f[0][u] = left[k - 1];
    for (int i = 0, _a = (k); i < _a; i++) {
      f[1][u] = (f[1][u] + f1[i] * ((i > 0) ? left[i - 1] : 1) % MOD *
                               ((i < k - 1) ? right[i + 1] : 1)) %
                MOD;
    }
  } else {
    f[0][u] = 0;
    f[1][u] = left[k - 1];
  }
}
int main() {
  ios ::sync_with_stdio(false);
  while (cin >> n) {
    init();
    for (int i = (2), _b = (n); i <= _b; i++) {
      int fi;
      cin >> fi;
      ++fi;
      ke[fi].push_back(i);
    }
    for (int i = (1), _b = (n); i <= _b; i++) cin >> col[i];
    dfs(1);
    cout << f[1][1] << endl;
  }
  return 0;
}
