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;
vector<vector<int> > G;
vector<int> COLOR;
vector<vector<long long> > DP;
const long long mod = 1e9 + 7;
void solve(int vId, int parentId) {
  if (G[vId].size() > 1 || vId == 0) {
    for (int i = 0; i < G[vId].size(); ++i) {
      if (parentId != G[vId][i]) solve(G[vId][i], vId);
    }
    if (COLOR[vId] == 0) {
      deque<long long> lRange;
      deque<long long> center;
      long long prev = 1;
      for (int i = 0; i < G[vId].size(); ++i) {
        int w = G[vId][i];
        if (w != parentId) {
          lRange.push_back(prev * (DP[w][0] + DP[w][1]));
          lRange[lRange.size() - 1] %= mod;
          prev = lRange[lRange.size() - 1];
          center.push_back(DP[w][1]);
        }
      }
      deque<long long> rRange;
      prev = 1;
      for (int i = (int)G[vId].size() - 1; i >= 0; --i) {
        int w = G[vId][i];
        if (w != parentId) {
          rRange.push_front(prev * (DP[w][0] + DP[w][1]));
          rRange[0] %= mod;
          prev = rRange[0];
        }
      }
      DP[vId][1] = 0;
      for (int i = 0; i < center.size(); ++i) {
        long long left = i == 0 ? 1 : lRange[i - 1];
        long long right = i == center.size() - 1 ? 1 : rRange[i + 1];
        DP[vId][1] += ((left * center[i]) % mod) * right;
        DP[vId][1] %= mod;
      }
      long long su = 1;
      for (int i = 0; i < G[vId].size(); ++i) {
        int w = G[vId][i];
        if (w != parentId) su = su * (DP[w][0] + DP[w][1]);
        su %= mod;
      }
      DP[vId][0] = su;
    } else {
      DP[vId][0] = 0;
      long long su = 1;
      for (int i = 0; i < G[vId].size(); ++i) {
        int w = G[vId][i];
        if (w != parentId) su = su * (DP[w][0] + DP[w][1]);
        su %= mod;
      }
      DP[vId][1] = su;
    }
  } else {
    if (COLOR[vId] == 1) {
      DP[vId][1] = 1;
      DP[vId][0] = 0;
    } else {
      DP[vId][1] = 0;
      DP[vId][0] = 1;
    }
  }
}
int main() {
  int n;
  cin >> n;
  DP = vector<vector<long long> >(n, vector<long long>(2, 0));
  vector<vector<int> > graph(n, vector<int>());
  for (int i = 0; i < n - 1; ++i) {
    int pi;
    cin >> pi;
    graph[i + 1].push_back(pi);
    graph[pi].push_back(i + 1);
  }
  G = graph;
  vector<int> color(n);
  for (int i = 0; i < n; ++i) cin >> color[i];
  COLOR = color;
  solve(0, -1);
  cout << DP[0][1] << endl;
  return 0;
}
