Given a tree with vertices. Each vertex has a value . For vertex and , if some vextex is on the path between and , and is neither nor , we update . means the greatest common divisor function. is an array of zeros initial.
Find the array after all updation.
First line contains an integer .
Second line contains integers, represent the array .
Each of the next lines contains two integers , represent an edge in the tree.
integers in one line, represent the array , separated by space.
Vertex is updated by and ,
Vertex is updated by and ,
Vertex is updated by and ,