def mergeFlags(a, b):
    """
    Merges the dictonaries a and b and returns a new one.
    Assumes that the dictonary values are lists.
    If a key exists in both then the new dictionary will have a list
    with the contents of both input lists in it.
    """
    result = {}
    result.update(a)
    for key in b.keys():
        if key in result:
            result[key].extend(b[key])
        else:
            result[key] = b[key]
    return result