def topologicalSortUtil(self, x, visited, stack):
    if visited[x]:
        return
    for k in self.graph[x]:
        self.topologicalSortUtil(k, visited, stack)
    visited[x] = True
    stack.insert(0, x)
def topologicalSortUtil(self, x, visited, stack):
    if visited[x]:
        return
    for k in self.graph[x]:
        self.topologicalSortUtil(k, visited, stack)
    visited[x] = True
    stack.insert(0, x)