def sparseArraySum(a: dict, b: dict):
    vsum = {}

    ka = a.keys()
    kb = b.keys()

    sas = set()

    for i in ka:
        sas.add(i)
    
    for i in kb:
        sas.add(i)

    for k in sas:
        d = 0
        e = 0

        if k in a:
            d = a[k]
        
        if k in b:
            e = b[k]

        vsum[k] = d + e

    return vsum


da = {5:4, 9:2, 10:9}
db = {5:4, 9:2, 2:3}

print(sparseArraySum(da, db))