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;
static const long long PRIME = 1e9 + 7;
long long add(long long a, long long b) { return (a + b) % PRIME; }
long long mul(long long a, long long b) { return (a * b) % PRIME; }
long long inv(long long n) {
  n = n % PRIME;
  long long r = 1;
  long long pow = PRIME - 2;
  while (pow > 0) {
    if (pow & 1) {
      r = mul(r, n);
    }
    pow = pow >> 1;
    n = mul(n, n);
  }
  return r;
}
template <typename T>
struct two {
  long long n, m;
  vector<T> arr;
  two(long long x, long long y) : n(x), m(y), arr(x * y) {}
  T& at(long long x, long long y) { return arr[x + n * y]; }
};
struct solve {
  long long n;
  two<long long> dp;
  two<unsigned char> marked;
  vector<vector<long long>> children;
  vector<long long> colors;
  solve(long long nodes, const vector<vector<long long>>& ch,
        const vector<long long>& col)
      : n(nodes), dp(2, n), marked(2, n), children(ch), colors(col) {}
  long long get(long long a, long long b) {
    long long result;
    if (marked.at(a, b)) {
      result = dp.at(a, b);
    } else if (a == 0 && colors[b] == 1) {
      result = 0;
    } else if (a == 0 && colors[b] == 0 && children[b].size() == 0) {
      result = 1;
    } else if (a == 0 && colors[b] == 0 && children[b].size() > 0) {
      result = 1;
      for (const long long& child : children[b]) {
        result = mul(add(get(0, child), get(1, child)), result);
      }
    } else if (a == 1 && colors[b] == 1 && children[b].size() == 0) {
      result = 1;
    } else if (a == 1 && colors[b] == 1 && children[b].size() > 0) {
      result = 1;
      for (const long long& child : children[b]) {
        result = mul(add(get(0, child), get(1, child)), result);
      }
    } else if (a == 1 && colors[b] == 0 && children[b].size() == 0) {
      result = 0;
    } else if (a == 1 && colors[b] == 0 && children[b].size() > 0) {
      vector<long long> d1list;
      vector<long long> pairlist;
      bool zeroden = false;
      long long zeroindex;
      for (const long long& i : children[b]) {
        long long d0 = get(0, i);
        long long d1 = get(1, i);
        long long pair = add(d0, d1);
        d1list.push_back(d1);
        pairlist.push_back(pair);
        if (pair == 0) {
          zeroden = true;
          zeroindex = i;
        }
      }
      if (!zeroden) {
        long long prod = 1;
        long long sum = 0;
        for (long long i = 0; i < children[b].size(); i++) {
          prod = mul(prod, pairlist[i]);
          long long term = mul(d1list[i], inv(pairlist[i]));
          sum = add(sum, term);
        }
        result = mul(sum, prod);
      } else {
        long long prod = 1;
        for (const long long& j : children[b]) {
          if (j != zeroindex) {
            prod = mul(prod, pairlist[j]);
          } else {
            prod = mul(prod, d1list[j]);
          }
        }
        result = prod;
      }
    } else {
      assert(false);
    }
    dp.at(a, b) = result;
    marked.at(a, b) = true;
    return result;
  }
};
int main(int argc, char const* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  { scanf("%lld", &n); }
  vector<vector<long long>> children(n);
  {
    for (long long i = 1; i < n; i++) {
      long long v;
      scanf("%lld", &v);
      children[v].push_back(i);
    }
  }
  vector<long long> colors(n);
  {
    for (long long i = 0; i < n; i++) {
      scanf("%lld", &colors[i]);
    }
  }
  solve solution(n, children, colors);
  printf("%lld\n", solution.get(1, 0));
  return 0;
}
