• How to solve Disposable-Teleporters

Question related to mission Disposable teleports

declarations: My skills with graphs and trees is not good at all

I could generate the graph from input. I used following data structure to do so. graph = {'1':['2'], '2':['3'], '3':['4'], '4':['5'], '5':['6'], '6':['7'], '7':['8'], '8':['1']}

I tried a lot of ways to write an algorithm to visit all nodes but not successful.

Any guide?