#include <bits/stdc++.h>
#pragma warning(disable : 4786)
using namespace std;
vector<int> v[100010];
int dp[100010][2];
int s[100010];
int dfs(int x, int y, int z) {
  if (dp[x][z] >= 0) return dp[x][z];
  if (z == 0 && s[x] == 1) return dp[x][z] = 0;
  if (z == 0 || s[x] == 1) {
    long long ans = 1;
    for (int i = 0; i < v[x].size(); i++) {
      if (v[x][i] == y) continue;
      ans = ans * ((dfs(v[x][i], x, 0) + dfs(v[x][i], x, 1)) % 1000000007) %
            1000000007;
    }
    return dp[x][z] = ans;
  } else {
    long long dp2[2];
    dp2[0] = 1;
    dp2[1] = 0;
    for (int i = 0; i < v[x].size(); i++) {
      int tem1, tem2;
      if (v[x][i] == y) continue;
      tem1 = dfs(v[x][i], x, 0);
      tem2 = dfs(v[x][i], x, 1);
      dp2[1] = (dp2[0] * tem2 % 1000000007 +
                (dp2[1] * (tem1 + tem2) % 1000000007) % 1000000007) %
               1000000007;
      dp2[0] = (dp2[0] * (tem1 + tem2) % 1000000007) % 1000000007;
    }
    return dp[x][z] = dp2[1];
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int sp;
    cin >> sp;
    v[i + 1].push_back(sp);
    v[sp].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < n; i++) {
    dp[i][0] = dp[i][1] = -1;
  }
  cout << dfs(0, -1, 1) << endl;
}
