Skip to main content
1 of 2

Jelly, 10 bytes

DŒPḌḟiⱮÆfẠ 

Try it online!