I have gone over the scenarios in my head,
and there are 6.96969 billion outcomes, and only one of them -
- do I win.
Dream abstracts the fabric of spacetime as a directed rooted tree (arborescence) with
Then, Dream employs a magical superpower and adds
Let's call a node of this DAG an event and further call a simple path on this DAG an era. Dream considers a pair of events
Dream now wants you to answer
Constraints
The given tree and
Subtask 1 [1%]
The tree is a line graph.
Subtask 2 [11%]
Subtask 3 [7%]
Subtask 4 [23%]
Subtask 5 [17%]
Subtask 6 [41%]
No additional constraints.
Input Specification
The first line of the input contains two integers
The second line contains
The following line contains a single integer
Output Specification
For each query, print a single line containing one integer — the number of plausible pairs
Sample Input
8 2
1 2 5 1 4 3 3
2 4
4 7
3
4 6
5 7
1 8
Sample Output
6
5
27
Comments
TechnobladeNeverDies, henrybaolol9. TechnobladeNeverDies
And neither does Technoblade.
This comment is hidden due to too much negative feedback. Show it anyway.
TechnobladeNeverDies