You are given a tree with N nodes and N−1 edges. Each node i of the tree is assigned a color A[i]. Let c(x,y) be the array of colors encountered while traversing from node x to node y in the tree in the order.
Let f(x,y) represent the number of inversions in the array c(x,y).
You need to compute f(x,y)+f(y,x) for Q different queries.
Input format
Output format
For each query output the answer in a new line representing the value f(x,y)+f(y,x).
Constraints