#include <bits/stdc++.h>
using namespace std;
const unsigned long long MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
int n;
int *color;
vector<int> *child;
unsigned long long dp[MAXN][2];
int main() {
  scanf("%d", &n);
  child = new vector<int>[n];
  for (int i = 0; i < n - 1; ++i) {
    int x;
    scanf("%d", &x);
    child[x].push_back(i + 1);
  }
  color = new int[n];
  for (int i = 0; i < n; ++i) {
    scanf("%d", color + i);
  }
  for (int i = n - 1; i >= 0; --i) {
    if (color[i] == 0) {
      dp[i][0] = 1;
      dp[i][1] = 0;
      for (int k = 0; k < child[i].size(); ++k) {
        int u = child[i][k];
        dp[i][1] =
            (dp[i][0] * dp[u][1] + dp[i][1] * (dp[u][0] + dp[u][1])) % MOD;
        dp[i][0] = (dp[i][0] * (dp[u][0] + dp[u][1])) % MOD;
      }
    } else {
      dp[i][0] = 0;
      dp[i][1] = 1;
      for (int k = 0; k < child[i].size(); ++k) {
        int u = child[i][k];
        dp[i][1] = (dp[i][1] * (dp[u][0] + dp[u][1])) % MOD;
      }
    }
  }
  cout << dp[0][1] << endl;
  delete[] color;
  delete[] child;
  return 0;
}
