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 int MOD = 1000000007;
const long long BIG = 1446803456761533460LL;
const int Big = 336860180;
const long long int INF = LONG_LONG_MAX;
const vector<vector<long long int> > adj4({{0, 1}, {0, -1}, {1, 0}, {-1, 0}});
const vector<vector<long long int> > adj8(
    {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {-1, -1}, {1, -1}, {-1, 1}, {1, 1}});
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
bool isprime(long long int n) {
  if (n == 2 || n == 3) return true;
  if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
  for (long long int i = 6; (i - 1) * (i - 1) <= n; i += 6) {
    if (n % (i - 1) == 0 || n % (i + 1) == 0) {
      return false;
    }
  }
  return true;
}
vector<bool> sprime;
void genPrime(long long int sz) {
  sprime = vector<bool>(sz, true);
  sprime[0] = false;
  sprime[1] = false;
  for (long long int i = (2); i < (sz); ++i) {
    if (sprime[i]) {
      for (long long int j = i * i; j < sz; j += i) {
        sprime[j] = false;
      }
    }
  }
}
long long int powMod(long long int a, long long int b, long long int mod) {
  long long int n = 1;
  long long int p = a;
  while (b > 0) {
    if (b % 2 == 1) {
      n *= p;
      n %= mod;
    }
    p *= p;
    p %= mod;
    b /= 2;
  }
  return n;
}
long long int modularInverse(long long int a, long long int mod) {
  return powMod(a, mod - 2, mod);
}
long long int binarysearch(long long int l, long long int r,
                           bool (*bsfunction)(long long int)) {
  while (r - l > 1) {
    long long int mid = (l + r) / 2;
    bool val = bsfunction(mid);
    if (val) {
      r = mid;
    } else {
      l = mid;
    }
  }
  return l;
}
stringstream sss;
const long long int maxn = 100010;
vector<long long int> g[maxn];
long long int col[maxn];
long long int dp[maxn][2];
void dfs(long long int x) {
  long long int adjn = g[x].size();
  for (auto y : g[x]) {
    dfs(y);
  }
  vector<long long int> lt(adjn + 1), rt(adjn + 1);
  lt[0] = 1;
  rt[adjn] = 1;
  for (long long int i = 0; i < (adjn); ++i) {
    long long int y = g[x][i];
    lt[i + 1] = lt[i] * (dp[y][0] + dp[y][1]) % MOD;
  }
  for (long long int i = (adjn)-1; i >= 0; --i) {
    long long int y = g[x][i];
    rt[i] = rt[i + 1] * (dp[y][0] + dp[y][1]) % MOD;
  }
  if (col[x]) {
    dp[x][0] = 0;
    dp[x][1] = lt[adjn];
  } else {
    dp[x][0] = lt[adjn];
    for (long long int i = 0; i < (adjn); ++i) {
      long long int y = g[x][i];
      dp[x][1] += dp[y][1] * lt[i] % MOD * rt[i + 1] % MOD;
      dp[x][1] %= MOD;
    }
  }
}
void MAIN() {
  long long int n;
  cin >> n;
  for (long long int i = 0; i < (n - 1); ++i) {
    long long int x;
    cin >> x;
    g[x].push_back(i + 1);
  }
  for (long long int i = 0; i < (n); ++i) {
    cin >> col[i];
  }
  dfs(0);
  cout << (dp[0][1]) << endl;
}
long long int TESTCASEN = 1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  sss << R"(
10
0 1 2 1 4 4 4 0 8
0 0 0 1 0 1 1 0 0 1
    )";
  for (long long int test = 0; test < (TESTCASEN); ++test) {
    MAIN();
  }
  return 0;
}
