You are given a tree with nodes and edges and an integer . Each node has a label denoted by an integer, . Your task is to find the length of the longest path such that label of all the nodes in the path are divisible by .
Length of a path is the number of edges in that path.
Input Format:
First line contains two space separated integers, and . Next line contains space separated integers, integer denotes the label of node, . Next lines contains two space separated integers each, and denoting that there is an edge between node and node .
Output Format:
Print a single integer denoting the length of the longest path such that label of all the nodes in the path are divisible by .
Constraints:
Longest path will be 1->2->4.