#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 5, MOD = 1e9 + 7;
long long n;
long long par[MAXN];
long long cnt1[MAXN];
long long cnt2[MAXN];
long long dp1[MAXN];
long long dp2[MAXN];
long long color[MAXN];
bool subtree[MAXN];
vector<long long> G[MAXN];
void dfs_up1(long long v = 0) {
  for (long long i = 0; i < G[v].size(); i++) {
    dfs_up1(G[v][i]);
    subtree[v] |= subtree[G[v][i]];
  }
  subtree[v] |= color[v];
}
void dfs_up2(long long v = 0) {
  for (long long i = 0; i < G[v].size(); i++) dfs_up2(G[v][i]);
  if (!subtree[v]) {
    dp1[v] = 0;
    dp2[v] = 1;
    return;
  }
  if (color[v]) {
    dp1[v] = 1;
    for (long long i = 0; i < G[v].size(); i++)
      if (subtree[G[v][i]]) {
        if (color[G[v][i]]) dp1[v] = (dp1[v] * dp1[G[v][i]]) % MOD;
        if (!color[G[v][i]])
          dp1[v] = (dp1[v] * (dp1[G[v][i]] + dp2[G[v][i]])) % MOD;
      }
    dp2[v] = 0;
    return;
  }
  long long bu = 1, num = 0;
  for (long long i = 0; i < G[v].size(); i++)
    if (subtree[G[v][i]]) {
      if (color[G[v][i]]) {
        num++;
        bu = (bu * dp1[G[v][i]]) % MOD;
      }
      if (!color[G[v][i]]) bu = (bu * (dp1[G[v][i]] + dp2[G[v][i]])) % MOD;
    }
  dp1[v] = num * bu % MOD;
  bu = 1;
  num = 0;
  for (long long i = 0; i < G[v].size(); i++)
    if (subtree[G[v][i]]) {
      if (color[G[v][i]]) bu = (bu * dp1[G[v][i]]) % MOD;
      if (!color[G[v][i]]) {
        cnt1[num] =
            ((num ? cnt1[num - 1] : 1) * (dp1[G[v][i]] + dp2[G[v][i]])) % MOD;
        num++;
      }
    }
  long long ind = num - 1;
  for (long long i = G[v].size() - 1; ~i; i--)
    if (subtree[G[v][i]]) {
      if (!color[G[v][i]]) {
        cnt2[ind] = ((ind != num - 1 ? cnt2[ind + 1] : 1) *
                     (dp1[G[v][i]] + dp2[G[v][i]])) %
                    MOD;
        ind--;
      }
    }
  ind = 0;
  for (long long i = 0; i < G[v].size(); i++)
    if (subtree[G[v][i]]) {
      if (!color[G[v][i]]) {
        dp1[v] = (dp1[v] + bu * (ind ? cnt1[ind - 1] : 1) % MOD *
                               (ind + 1 != num ? cnt2[ind + 1] : 1) % MOD *
                               dp1[G[v][i]]) %
                 MOD;
        ind++;
      }
    }
  dp2[v] = 1;
  for (long long i = 0; i < G[v].size(); i++)
    if (subtree[G[v][i]]) {
      if (color[G[v][i]]) dp2[v] = (dp2[v] * dp1[G[v][i]]) % MOD;
      if (!color[G[v][i]])
        dp2[v] = (dp2[v] * (dp1[G[v][i]] + dp2[G[v][i]])) % MOD;
    }
}
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i < n; i++) {
    scanf("%lld", &par[i]);
    G[par[i]].push_back(i);
  }
  for (long long i = 0; i < n; i++) scanf("%lld", &color[i]);
  dfs_up1();
  dfs_up2();
  printf("%lld\n", dp1[0]);
  return 0;
}
