#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
long long dp[maxn][2];
int num[maxn];
vector<int> g[maxn];
long long q_mod(long long a, long long b, long long n) {
  long long ret = 1;
  long long tmp = a;
  while (b) {
    if (b & 0x1) ret = ret * tmp % n;
    tmp = tmp * tmp % n;
    b >>= 1;
  }
  return ret;
}
long long Del(long long x, long long y, long long z) {
  x = x * z;
  x = x % 1000000007;
  x = x * q_mod(y, 1000000007 - 2, 1000000007);
  x = x % 1000000007;
  return x;
}
void dfs(int x) {
  int flag = 0;
  long long sum = 1;
  int n = g[x].size();
  for (int i = 0; i < n; i++) {
    int y = g[x][i];
    dfs(y);
    flag = 1;
    sum *= dp[y][0];
    sum %= 1000000007;
  }
  if (!flag) {
    if (num[x]) {
      dp[x][0] = 1;
      dp[x][1] = 1;
    } else {
      dp[x][0] = 1;
      dp[x][1] = 0;
    }
    return;
  }
  if (num[x]) {
    dp[x][1] = sum;
    dp[x][0] = sum;
  } else {
    dp[x][0] = sum;
    dp[x][1] = 0;
    for (int i = 0; i < n; i++) {
      int y = g[x][i];
      dp[x][1] += Del(sum, dp[y][0], dp[y][1]);
      dp[x][1] %= 1000000007;
    }
    dp[x][0] += dp[x][1];
    dp[x][0] %= 1000000007;
  }
  return;
}
int main() {
  int n;
  while (cin >> n) {
    int x;
    for (int i = 0; i <= n; i++) g[i].clear();
    for (int i = 1; i < n; i++) {
      scanf("%d", &x);
      g[x].push_back(i);
    }
    for (int i = 0; i < n; i++) scanf("%d", &num[i]);
    memset(dp, 0, sizeof(dp));
    dfs(0);
    cout << dp[0][1] << endl;
  }
  return 0;
}
