def sum_dicts(a, b):
    """Sum the values of the two dicts, no matter which type they are.

    >>> sum_dicts({}, {})
    {}
    >>> sum_dicts({'a': 1}, {'a': 2})
    {'a': 3}
    >>> sum_dicts({'a': [1]}, {'a': [2], 'b': 3})
    {'b': 3, 'a': [1, 2]}
    >>> sum_dicts({'a': 1, 'b': 2, 'c': [1]}, {'b': 3, 'c': [4], 'd': [5]})
    {'c': [1, 4], 'b': 5, 'd': [5], 'a': 1}
    """

    merged = dict()
    if a is None or b is None:
        return a if a else b or {}

    for key in set(a) | set(b):
        value_a = a.get(key, type(b.get(key))())
        value_b = b.get(key, type(a.get(key))())
        if isinstance(value_a, dict) and isinstance(value_b, dict):
            merged[key] = sum_dicts(value_a, value_b)

        else:
            merged[key] = value_a + value_b

    return merged