You are tasked with solving a problem involving a tree structure consisting of N nodes and N−1 edges. Each node in the tree is associated with a distinct value A[i]. That means all the values of the nodes are distinct.
Your objective is to process Q queries, where each query provides three integers: X, Y, and K. Your goal is to determine the count of nodes along the simple path from node X to node Y (inclusive) such that the values of the nodes are divisible by K.
Input format
Output format
For each query output the answer in a new line representing the count of nodes divisible by K, on a path from Node X to Node Y inclusive.
Constraints
For test case 1: