from typing import Dict
from typing import List
from typing import Tuple


def invert_dict(orig: Dict[str, List[Tuple[int, str]]]) -> Dict[str, List[str]]:
    """Inverts the dict returned in convert: values to keys and keys to values.
    The original values is a list of tuples, each of them transformed to a key
    in the result. The key used is the second element of the tuple."""
    dest = dict()
    # For each element in the dictionary, collect all the keys where in
    # which that element is present in the dict values
    for elem in orig:
        dest[elem] = [k for k, v in orig.items() if elem in [tup[1] for tup in v]]
    return dest