#include <bits/stdc++.h>
using namespace std;
const int N = 100010, M = N << 1;
const int MOD = 1000000007;
int n, c[N], son[N];
int head[N], pre[M], nxt[M], e;
long long dp[N][2], ans;
void init() {
  memset(head, -1, sizeof(head));
  e = 0;
}
void addedge(int u, int v) { pre[e] = v, nxt[e] = head[u], head[u] = e++; }
void dfs(int u, int f) {
  son[u] = c[u];
  dp[u][0] = c[u] ? 0 : 1;
  dp[u][1] = c[u] ? 1 : 0;
  for (int i = head[u]; ~i; i = nxt[i]) {
    int v = pre[i];
    if (v == f) continue;
    dfs(v, u);
    if (son[v] == 0) continue;
    if (c[u] == 1) {
      if (c[v] == 1)
        ans = ans * dp[v][1] % MOD;
      else
        dp[u][1] = dp[u][1] * (dp[v][0] + dp[v][1]) % MOD;
    } else {
      dp[u][1] = dp[u][1] * (dp[v][0] + dp[v][1]) % MOD;
      dp[u][1] = (dp[u][1] + dp[u][0] * dp[v][1]) % MOD;
      dp[u][0] = dp[u][0] * (dp[v][0] + dp[v][1]) % MOD;
    }
    son[u] += son[v];
  }
}
int main() {
  scanf("%d", &n);
  int p;
  init();
  for (int i = 1; i < n; ++i) {
    scanf("%d", &p);
    addedge(p, i);
    addedge(i, p);
  }
  ans = 1;
  bool flag = true;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
    if (c[i] == 1) flag = false;
  }
  if (flag) {
    puts("1");
    return 0;
  }
  for (int i = 0; i < n; ++i)
    if (c[i] == 1) {
      dfs(i, -1);
      cout << ans * dp[i][1] % MOD << endl;
      break;
    }
  return 0;
}
