Please help me in HACKEREARTH Question: GCD ON TREE

how to solve this problem?

problem link: GCD on Tree | Practice Problems

how to apply centroid decomposition in this problem? or any other approach to solve this problem?

I got 3 points from that problem from last month’s Circuits and increased my rank by 2. I can help xD
Open editorial and check others solutions, there’s some nice clean solutions there. Other than centroid decomposition I saw a few dsu solutions, I remember as them easier to understand and faster. There’s a few days left for October Circuits, let me go check again.

@tieros
can you give me some hint or any approach?