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 long long MOD = 1000000007;
const int MN = 100111;
long long f[2][MN];
vector<int> ke[MN];
int n, col[MN];
void init() {
  for (int i = (1), _b = (n); i <= _b; i++) ke[i].clear();
  memset(f, 0, sizeof f);
}
void dfs(int u) {
  if (ke[u].size() == 0) {
    if (col[u] == 0) {
      f[0][u] = 1;
      f[1][u] = 0;
    } else {
      f[0][u] = 0;
      f[1][u] = 1;
    }
    return;
  }
  vector<long long> f0;
  vector<long long> f1;
  vector<long long> left, right;
  int k = ke[u].size();
  f0.resize(k);
  f1.resize(k);
  left.resize(k);
  right.resize(k);
  for (int i = 0, _a = (k); i < _a; i++) {
    int v = ke[u][i];
    dfs(v);
    f0[i] = f[0][v];
    f1[i] = f[1][v];
  }
  for (int i = 0, _a = (k); i < _a; i++) {
    if (i == 0) {
      left[i] = (f0[i] + f1[i]) % MOD;
    } else {
      left[i] = (left[i - 1] * f0[i] + left[i - 1] * f1[i]) % MOD;
    }
  }
  for (int i = (k - 1), _b = (0); i >= _b; i--) {
    if (i == k - 1) {
      right[i] = (f0[i] + f1[i]) % MOD;
    } else {
      right[i] = (right[i + 1] * (f0[i] + f1[i])) % MOD;
    }
  }
  if (col[u] == 0) {
    f[0][u] = left[k - 1];
    for (int i = 0, _a = (k); i < _a; i++) {
      f[1][u] = (f[1][u] + f1[i] * ((i > 0) ? left[i - 1] : 1) % MOD *
                               ((i < k - 1) ? right[i + 1] : 1)) %
                MOD;
    }
  } else {
    f[0][u] = 0;
    f[1][u] = left[k - 1];
  }
}
int main() {
  ios ::sync_with_stdio(false);
  while (cin >> n) {
    init();
    for (int i = (2), _b = (n); i <= _b; i++) {
      int fi;
      cin >> fi;
      ++fi;
      ke[fi].push_back(i);
    }
    for (int i = (1), _b = (n); i <= _b; i++) cin >> col[i];
    dfs(1);
    cout << f[1][1] << endl;
  }
  return 0;
}
