def update_dictionary(d, key, value):
    if key in d:
        d[key].append(value)
    if key not in d:
        if key*2 in d:
            d[key*2].append(value)
        if key*2 not in d:
            d[key*2] = [value]