Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.

Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the tree, then it will split into (k + 1) parts. Note, that each part will be a tree with colored vertices.

Now Appleman wonders, what is the number of sets splitting the tree in such a way that each resulting part will have exactly one black vertex? Find this number modulo 1000000007 (109 + 7).

Input

The first line contains an integer n (2 ≤ n ≤ 105) — the number of tree vertices. 

The second line contains the description of the tree: n - 1 integers p0, p1, ..., pn - 2 (0 ≤ pi ≤ i). Where pi means that there is an edge connecting vertex (i + 1) of the tree and vertex pi. Consider tree vertices are numbered from 0 to n - 1.

The third line contains the description of the colors of the vertices: n integers x0, x1, ..., xn - 1 (xi is either 0 or 1). If xi is equal to 1, vertex i is colored black. Otherwise, vertex i is colored white.

Output

Output a single integer — the number of ways to split the tree modulo 1000000007 (109 + 7).

Examples

Input

3
0 0
0 1 1


Output

2


Input

6
0 1 1 0 4
1 1 0 0 1 0


Output

1


Input

10
0 1 2 1 4 4 4 0 8
0 0 0 1 0 1 1 0 0 1


Output

27
#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1001, MOD = 1e9 + 7;
long long n, dp[N][2];
long long r[N], l[N];
bool black[N];
vector<int> adj[N];
long long _mul(long long a, long long b) { return (1LL * a * b) % MOD; }
long long _sum(long long a, long long b) { return (a + b) % MOD; }
void dfs(int u, int par = -1) {
  int size = adj[u].size();
  if (size == 1 && par != -1) {
    dp[u][1] = black[u], dp[u][0] = !black[u];
    return;
  }
  for (auto v : adj[u])
    if (v != par) dfs(v, u);
  l[0] = r[size - 1] = 1;
  for (int i = 0; i < size; i++) {
    if (adj[u][i] != par)
      l[i + 1] = _mul(l[i], dp[adj[u][i]][0] + dp[adj[u][i]][1]);
    else
      l[i + 1] = l[i];
  }
  for (int i = size - 1; 0 < i; i--) {
    if (adj[u][i] != par)
      r[i - 1] = _mul(r[i], dp[adj[u][i]][0] + dp[adj[u][i]][1]);
    else
      r[i - 1] = r[i];
  }
  if (black[u])
    dp[u][1] = l[size];
  else
    for (int i = 0; i < size; i++) {
      if (adj[u][i] != par)
        dp[u][1] = _sum(dp[u][1], _mul(_mul(l[i], r[i]), dp[adj[u][i]][1]));
    }
  dp[u][0] = !black[u] * l[size];
}
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u;
    cin >> u;
    adj[i].push_back(u);
    adj[u].push_back(i);
  }
  for (int i = 0; i < n; i++) cin >> black[i];
  dfs(0);
  cout << dp[0][1] << "\n";
}
