Ada is working on a science project for school. She is studying evolution and she would like to compare how different species of organisms would perform when trying to solve a coding competition problem.
The $\mathbf{N}$ species are numbered with integers between $1$ and $\mathbf{N}$, inclusive. Species $1$ has no direct ancestor, and all other species have exactly one direct ancestor each, from which they directly evolved. A (not necessarily direct) ancestor of species $x$ is any other species $y$ such that $y$ can be reached from $x$ by moving one or more times to a species direct ancestor starting from $x$. In this way, species $1$ is a (direct or indirect) ancestor of every other species.
Through complex genetic simulations, she calculated the average score each of the $\mathbf{N}$ species would get in a particular coding competition. $\mathbf{S_i}$ is that average score for species $i$.
Ada is looking for interesting triplets to showcase in her presentation. An interesting triplet is defined as an ordered triplet of distinct species $(a, b, c)$ such that:
Given the species scores and ancestry relationships, help Ada by writing a program to count the total number of interesting triplets.
The first line of the input gives the number of test cases, $\mathbf{T}$. $\mathbf{T}$ test cases follow.
The first line of each test case contains two integers $\mathbf{N}$ and $\mathbf{K}$, denoting the number of species and the factor which determines interesting triplets, respectively.
The second line of each test case contains $\mathbf{N}$ integers $\mathbf{S_1}, \mathbf{S_2}, \dots, \mathbf{S_N}$, where $\mathbf{S_i}$ denotes the average score of species $i$.
The third line of each test case contains $\mathbf{N}-1$ integers $\mathbf{P_2}, \mathbf{P_3}, \dots, \mathbf{P_N}$, meaning species $\mathbf{P_i}$ is the direct ancestor of species $i$.
For each test case, output one line containing Case #x: y, where $x$ is the test case number (starting from 1) and $y$ is the total number of interesting triplets according to Ada's definition.

In Sample Case #1, there is only one possible interesting triplet: $(5, 3, 4)$. Indeed, we can verify that:

In Sample Case #2, there are seven interesting triplets: