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 = (int)200004;
const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, 1, 0, -1, -1, 1, -1, 1};
char dir[] = {'L', 'D', 'R', 'U'};
const long long int mod = (long long int)1e9 + 7;
const long long int inf = 1e18 + 1000;
int BIT[200005], n;
long long int prime[17], spf[N];
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <typename T>
T min3(T a, T b, T c) {
  return min(a, min(b, c));
}
template <typename T>
T max3(T a, T b, T c) {
  return max(a, max(b, c));
}
bool isVowel(char ch) {
  ch = toupper(ch);
  if (ch == 'A' || ch == 'U' || ch == 'I' || ch == 'O' || ch == 'E')
    return true;
  return false;
}
long long int mInv(long long int a, long long int m) {
  long long int m0 = m;
  long long int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long int q = a / m;
    long long int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
long long int power(long long int x, long long int y) {
  long long int res = 1;
  x = x % mod;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long Extendedgcd(long long a, long long b, long long *x, long long *y) {
  if (!a) {
    *x = 0;
    *y = 1;
    return b;
  }
  long long nx, ny;
  long long d = Extendedgcd(b % a, a, &nx, &ny);
  long long k = b / a;
  *y = nx;
  *x = -k * nx + ny;
  return d;
}
void update(int x, int delta) {
  if (!x) {
    BIT[x] += delta;
    return;
  }
  for (; x <= N; x += x & -x) BIT[x] += delta;
}
long long int query(int x) {
  long long int sum = BIT[0];
  for (; x > 0; x -= x & -x) sum += BIT[x];
  return sum;
}
void Sieve() {
  for (int i = 1; i <= N; i++) prime[i] = 1;
  prime[0] = 0;
  prime[1] = 0;
  for (long long int p = 2; p * p <= N; p++) {
    if (prime[p] == 1) {
      for (long long int i = p * p; i <= N; i += p) prime[i] = 0;
    }
  }
  for (int p = 3; p <= N; p++) prime[p] += prime[p - 1];
}
void sieve() {
  spf[1] = -1;
  for (int i = 2; i < N; i++) spf[i] = i;
  for (int i = 4; i < N; i += 2) spf[i] = 2;
  for (long long int i = 3; i * i < N; i++) {
    if (spf[i] == i) {
      for (long long int j = i * i; j < N; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
struct cmp {
  bool operator()(const pair<int, int> &x, const pair<int, int> &y) const {
    if (x.first != y.first) return x.first < y.first;
    return x.second > y.second;
  }
};
void gInput(int m, vector<int> adj[]) {
  int u, v;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
}
vector<long long int> fac;
void factorial() {
  int N = (int)3e5 + 100;
  fac.resize(N);
  fac[0] = 1;
  for (long long int i = 1; i < N; i++) {
    fac[i] = ((fac[i - 1] % mod) * i) % mod;
  }
}
long long int nCr(long long int n, long long int r) {
  long long int x = fac[n];
  long long int y = fac[r];
  long long int z = fac[n - r];
  long long int pr = ((y % mod) * (z % mod)) % mod;
  pr = mInv(pr, mod);
  long long int ncr = ((x % mod) * (pr % mod)) % mod;
  return ncr;
}
long long int dp[100003][2];
int a[100003];
void dfs(int node, vector<int> adj[], int pr) {
  if (a[node] == 1) {
    dp[node][1] = 1;
    dp[node][0] = 0;
  } else {
    dp[node][1] = 0;
    dp[node][0] = 1;
  }
  for (int j : adj[node]) {
    if (j != pr) {
      dfs(j, adj, node);
      long long int res_w = 0, res_b = 0;
      res_w = (res_w + dp[node][0] * dp[j][0]) % mod;
      res_b = (res_b + (dp[node][1] * dp[j][0]) % mod +
               (dp[node][0] * dp[j][1]) % mod) %
              mod;
      ;
      res_w = (res_w + dp[node][0] * dp[j][1]) % mod;
      res_b = (res_b + dp[node][1] * dp[j][1]) % mod;
      dp[node][0] = res_w;
      dp[node][1] = res_b;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    vector<int> adj[n + 1];
    int x;
    for (int i = 0; i < n - 1; i++) {
      cin >> x;
      adj[i + 1].push_back(x);
      adj[x].push_back(i + 1);
    }
    for (int i = 0; i < n; i++) cin >> a[i];
    dfs(0, adj, 0);
    cout << dp[0][1] << "\n";
  }
  return 0;
}
