from typing import Dict
from typing import Any


def change_dict_keys(new_names_dict: Dict[str, str], output_dict: Dict[str, Any]) -> Dict[str, Any]:
    """
    Takes a dictionary and changes the names of the keys
    Args:
        new_names_dict: a dictionary with the old names as keys and their new names as their values
        output_dict: Dictionary with string keys
    Returns:
        Same dictionary but with keys with the new names or the same dictionary if the old keys don't exist
    Raises:
        TypeError: output_dict is not a dictionary
    """
    for key, new_name in new_names_dict.items():
        if key in output_dict:
            output_dict[new_name] = output_dict.pop(key)
    return output_dict