Help with CSES problem Common Divisors

Not a source, but here

@everule1 sir’s teaching is orz