def merge_ref_dicts(first_dict, second_dict):
    """ Merge dictionaries mapping reference positions to base identities. """
    merged_dict = {}
    merged_dict.update(first_dict)
    for position, base in second_dict.items():
        if position in merged_dict:
            if merged_dict[position] != base:
                raise ValueError(first_dict, second_dict)
        else:
            merged_dict[position] = base
    return merged_dict
