import copy
from functools import reduce


def deep_merge(*dicts) -> dict:
    """
    Merges dicts deeply.

    Pass the dictionaries to merge as parameters to the function.

    Args:
        *dicts: Dicts to merge with the first one as the base

    Returns:
        dict: The merged dict
    """

    def merge_into(d1, d2):
        for key in d2:
            if key not in d1 or not isinstance(d1[key], dict):
                d1[key] = copy.deepcopy(d2[key])
            else:
                d1[key] = merge_into(d1[key], d2[key])
        return d1

    return reduce(merge_into, dicts, {})