there tree ie connect undirected graph cycle consist n node number 0 n 1 exactly n 1 edge each node value associate root tree node 0to represent tree give integer array num 2D array edge each numsi represent ith node value edgesj uj vj represent edge node uj vj treeTwo value x y coprime gcdx y 1 gcdx y great common divisor x yAn ancestor node node short path node root a node consider ancestor itselfReturn array ans size n ansi close ancestor node numsi numsansi coprime 1 ancestor Example 1input num 2332 edge 011213output 1001explanation in figure node value parenthese Node 0 coprime ancestor Node 1 ancestor node 0 their value coprime gcd23 1 Node 2 ancestor nod 1 0 Node 1s value coprime gcd33 3 node 0s value gcd23 1 node 0 close valid ancestor Node 3 ancestor nod 1 0 it coprime node 1 gcd32 1 node 1 close valid ancestorexample 2input num 561023615 edge 010213142526output 1010001 Constraintsnumslength n1 numsi 501 n 105edgeslength n 1edgesjlength 20 uj vj nuj vj