Please help me in HACKEREARTH Question: GCD ON TREE

how to solve this problem?

problem link: https://www.hackerearth.com/problem/algorithm/gcd-on-tree-6c5cdfba/description/

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?

//