Given an Integer K and a tree of N vertices where each vertex consists of a value Vi associated to it. Find the longest path in the tree which satisfies the following conditions
Input Format
First line consists of two integers N and K.
Next N−1 lines consists of two integers ui and vi representing an edge between ui and vi.
Next line consists of N space separated integers where ith of them is the value Vi associated to ith vertex.
Output Format
Print an Integer representing the longest path as described in the problem statement.
Constraints
Longest Path is 4−3−2−6−7−8 of length 6
gcd(V4,V3)=gcd(30,5)=5>1
gcd(V2,V6)=gcd(9,21)=3>1
gcd(V7,V8)=gcd(6,3)=3>1