<s>[INST] class Solution:
    def canVisitAllRooms(self, rooms: List[List[int]]) -> bool:
        visited = [False] * len(rooms)
        visited[0] = True
        stack = [0]
        while stack:
            cur_room = stack.pop()
            for room in rooms[cur_room]:
                if not visited[room]:
                    stack.append(room)
                    visited[room] = True
        return all(visited)[/INST]