#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000000")
const long long int INF = 2e15 + 1;
using namespace std;
vector<long long int> g[2000010];
long long int cnt[2000010][2];
long long int color[2000010];
long long int mod = 1000000007;
vector<long long int> d;
long long int binpow(long long int a, long long int b) {
  if (!b) return 1;
  if (b & 1) {
    return (a * binpow(a, b - 1)) % mod;
  }
  long long int te = binpow(a, b / 2);
  return (te * te) % mod;
}
void dfs(long long int id, long long int p) {
  long long int q = -1;
  for (long long int(i) = 0; (i) < ((long long int)(g[id]).size()); (i)++) {
    long long int to = g[id][i];
    if (to == p) continue;
    dfs(to, id);
    if (color[id]) {
      if (cnt[to][1] != -1) {
        if (q == -1) {
          q = cnt[to][1];
        } else
          q = (q * cnt[to][1]) % mod;
      }
    } else {
      if (cnt[to][1] != -1) {
        if (cnt[id][1] == -1)
          cnt[id][1] = cnt[to][1];
        else
          cnt[id][1] = (cnt[id][1] * cnt[to][1]) % mod;
      }
    }
  }
  if (q != -1) d.push_back(q);
  if (color[id]) {
    cnt[id][0] = cnt[id][1] = 1;
  } else if (cnt[id][1] != -1) {
    cnt[id][0] = 0;
    for (long long int(i) = 0; (i) < ((long long int)(g[id]).size()); (i)++) {
      long long int to = g[id][i];
      if (to == p || cnt[to][1] == -1) continue;
      long long int all = (cnt[id][1] * binpow(cnt[to][1], mod - 2)) % mod;
      cnt[id][0] = (cnt[id][0] + (all * cnt[to][0]) % mod) % mod;
    }
    cnt[id][1] = (cnt[id][1] + cnt[id][0]) % mod;
  } else {
    cnt[id][0] = 0;
    cnt[id][1] = 1;
  }
}
int main() {
  memset(cnt, -1, sizeof cnt);
  long long int n;
  cin >> n;
  for (long long int(i) = 0; (i) < (n - 1); (i)++) {
    long long int with;
    cin >> with;
    g[with].push_back(i + 1);
    g[i + 1].push_back(with);
  }
  for (long long int(i) = 0; (i) < (n); (i)++) {
    cin >> color[i];
  }
  for (long long int(i) = 0; (i) < (n); (i)++) {
    if (color[i]) {
      dfs(i, -1);
      break;
    }
  }
  if (!(long long int)(d).size()) {
    cout << 0;
  } else {
    long long int ans = 1;
    for (long long int(i) = 0; (i) < ((long long int)(d).size()); (i)++) {
      ans = (ans * d[i]) % mod;
    }
    cout << ans;
  }
}
