import copy


def merge_rows(row1, row2):
    """Merge two rows of the table of CVE data"""
    output = copy.deepcopy(row1)
    for key in row2:
        if key not in output:
            output[key] = row2[key]
        elif output[key] == row2[key]:
            continue
        elif key == 'References':
            output['References'].update(row2['References'])
        elif key == 'Severity':
            if output['Severity'] == 'Critical' or row2['Severity'] == 'Critical':
                output['Severity'] = 'Critical'
            else:
                output[key] = '{old}, {new}'.format(old=output[key], new=row2[key])
        else:
            output[key] = '{old}, {new}'.format(old=output[key], new=row2[key])
    return output