#include <bits/stdc++.h>
using namespace std;
bool color[100001];
vector<long long> graph[100001], fr, rev, on;
long long one[100001], zero[100001];
long long ans = 0;
void bfs(long long curr, long long prev) {
  if (graph[curr].size() == 1 && graph[curr][0] == prev) {
    if (color[curr] == 0) {
      one[curr] = 0;
      zero[curr] = 1;
    } else {
      one[curr] = 1;
      zero[curr] = 0;
    }
    return;
  }
  long long a1 = 1, a0 = 1;
  for (long long i = 0; i < graph[curr].size(); i++) {
    if (prev != graph[curr][i]) {
      bfs(graph[curr][i], curr);
    }
  }
  fr.clear(), rev.clear(), on.clear();
  for (long long i = 0; i < graph[curr].size(); i++) {
    if (prev != graph[curr][i]) {
      a0 = (a0 * (zero[graph[curr][i]] + one[graph[curr][i]]) % 1000000007) %
           1000000007;
      fr.push_back(a0);
      on.push_back(one[graph[curr][i]]);
    }
    if (prev != graph[curr][graph[curr].size() - 1 - i]) {
      a1 = (a1 *
            (zero[graph[curr][graph[curr].size() - 1 - i]] +
             one[graph[curr][graph[curr].size() - 1 - i]]) %
            1000000007) %
           1000000007;
      rev.push_back(a1);
    }
  }
  a1 = 0;
  for (long long i = 0; i < fr.size(); i++) {
    long long b = 1;
    if (i > 0) b = (b * fr[i - 1]) % 1000000007;
    long long c = fr.size() - i - 2;
    if (c >= 0) b = (b * rev[c]) % 1000000007;
    b = (b * on[i]) % 1000000007;
    a1 = (a1 + b) % 1000000007;
  }
  if (color[curr] == 1) {
    zero[curr] = 0;
    one[curr] = a0;
  } else {
    zero[curr] = a0;
    one[curr] = a1;
  }
}
int main() {
std:
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long a;
    cin >> a;
    graph[a].push_back(i);
    graph[i].push_back(a);
  }
  for (long long i = 0; i < n; i++) cin >> color[i];
  bfs(0, -1);
  if (color[0] == 0)
    cout << one[0] << endl;
  else
    cout << one[0] << endl;
}
