#include <bits/stdc++.h>
using namespace std;
bool vis[100000] = {false};
int dp[100000][2] = {0};
int ans = 1;
void dfs(vector<int> *v, int root, bool *vis, int *col) {
  vis[root] = 1;
  dp[root][0] = 1 - col[root];
  dp[root][1] = col[root];
  for (int i = 0; i < v[root].size(); i++) {
    int a = v[root][i];
    if (vis[a] != 1) {
      dfs(v, a, vis, col);
      int x, y;
      x = dp[root][0];
      y = dp[root][1];
      dp[root][0] = dp[root][1] = 0;
      dp[root][0] =
          (dp[root][0] + ((long long)x * dp[a][0]) % 1000000007) % 1000000007;
      dp[root][0] =
          (dp[root][0] + ((long long)x * dp[a][1]) % 1000000007) % 1000000007;
      dp[root][1] =
          (dp[root][1] + ((long long)y * dp[a][0]) % 1000000007) % 1000000007;
      dp[root][1] =
          (dp[root][1] + ((long long)x * dp[a][1]) % 1000000007) % 1000000007;
      dp[root][1] =
          (dp[root][1] + ((long long)y * dp[a][1]) % 1000000007) % 1000000007;
    }
  }
}
const int dir[4][2] = {0, -1, 0, 1, -1, 0, 1, 0};
int main() {
  int i, n;
  cin >> n;
  vector<int> v[100000];
  for (i = 0; i < n - 1; i++) {
    int a;
    cin >> a;
    v[i + 1].push_back(a);
    v[a].push_back(i + 1);
  }
  int col[100000], k = 0;
  for (i = 0; i < n; i++) {
    int a;
    cin >> a;
    col[i] = a;
  }
  dfs(v, 0, vis, col);
  cout << dp[0][1] << endl;
  return 0;
}
