Help me in solving PLNTPATHC problem

My issue

Not able to solve the problem Planetary Path

My code

# cook your dish here

Learning course: Data structures & Algorithms lab
Problem Link: Planetary Path in Data structures & Algorithms lab