def topology_sort(
    graph: dict[int, list[int]], vert: int, visited: list[bool]
) -> list[int]:

    visited[vert] = True
    order = []

    for neighbour in graph[vert]:
        if not visited[neighbour]:
            order += topology_sort(graph, neighbour, visited)

    order.append(vert)

    return order