def remap(diff):
    """Changes the format of a chain diff.
    
    :param diff: A diff in the format {district: [node 1, node 2, ...]}
    :returns: A diff in the format {node 1: district, node 2: district, ...}
    """
    flipped = {}
    for district, nodes in diff.items():
        for node in nodes:
            flipped[node] = district
    return flipped