from typing import Dict
from typing import List
import copy


def get_neighbors(state: Dict[int, List[int]]) -> List[Dict[int, List[int]]]:
    """given a state, return its neighbors

    for each processor, move its task to another processor and add it as 
    neighbor

    :param state: the root state

    :return: list of all neighbors
    """
    neighbors = []

    for source in range(len(state)):
        for task_id in range(len(state[source])):
            for destination in range(len(state)):
                # moving a task to its source is useless
                if destination == source:
                    continue

                # creating the neighbor
                neighbors.append(copy.deepcopy(state))

                # removing the task
                task = neighbors[-1][source].pop(task_id)

                # add it to the other processor
                new_tasklist = neighbors[-1][destination][:]
                new_tasklist.append(task)
                neighbors[-1][destination] = sorted(new_tasklist)

    return neighbors