Topological Sort Python Code For Snake