#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100009;
vector<vector<int> > ch(MaxN);
vector<int> par(MaxN);
vector<bool> color(MaxN);
vector<int> d(6 * MaxN);
long long yes[MaxN];
long long no[MaxN];
const int INF = 1000000007;
void build(int i, int l, int r, int A) {
  if (l + 1 == r)
    d[i] = (yes[ch[A][l]] + no[ch[A][l]]) % INF;
  else {
    int m = (l + r) / 2;
    build(2 * i + 1, l, m, A);
    build(2 * i + 2, m, r, A);
    d[i] = ((long long)d[2 * i + 1] * d[2 * i + 2]) % INF;
  }
}
int get(int i, int l, int r, int a, int b) {
  if (l >= b || r <= a) return 1;
  if (l >= a && r <= b) return d[i];
  int m = (l + r) / 2;
  int q = get(2 * i + 1, l, m, a, b);
  int w = get(2 * i + 2, m, r, a, b);
  return ((long long)q * w) % INF;
}
void dfs(int a) {
  if (ch[a].size() == 0) {
    if (color[a]) {
      no[a] = 0;
      yes[a] = 1;
    } else {
      yes[a] = 0;
      no[a] = 1;
    }
    return;
  }
  for (int i = 0; i < ch[a].size(); i++) {
    dfs(ch[a][i]);
  }
  if (color[a]) {
    no[a] = 0;
    long long s = 1;
    for (int i = 0; i < ch[a].size(); i++) {
      s = (s * (long long)(no[ch[a][i]] + yes[ch[a][i]])) % INF;
    }
    yes[a] = s;
  } else {
    long long s = 1;
    for (int i = 0; i < ch[a].size(); i++) {
      s = (s * (long long)(no[ch[a][i]] + yes[ch[a][i]])) % INF;
    }
    no[a] = s;
    s = 0;
    build(0, 0, ch[a].size(), a);
    for (int i = 0; i < ch[a].size(); i++) {
      int z = get(0, 0, ch[a].size(), 0, i);
      int x = get(0, 0, ch[a].size(), i + 1, ch[a].size());
      s = (s + (((((long long)z * x) % INF) * yes[ch[a][i]]) % INF)) % INF;
    }
    yes[a] = s;
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    par[i] = a;
    ch[a].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    bool e;
    cin >> e;
    color[i] = e;
  }
  dfs(0);
  cout << yes[0] << endl;
  return 0;
}
