import copy


def merge_qedges(qedges1: dict, qedges2: dict) -> dict:
    """Merge qedges: the keys must be the same and the values must be the same.
    If a key is unique to one edges dict, then the edge will be concatenated to
    the new edges dictionary. If a particular key exists in both messages but
    the values do not match, this will result in an error."""
    new_edges = copy.deepcopy(qedges1)
    for qedge_key, qedge_value in qedges2.items():
        if qedge_key not in new_edges:
            new_edges[qedge_key] = copy.deepcopy(qedge_value)
        elif qedge_value != new_edges[qedge_key]:
            raise ValueError(
                "Key exists in both messages but values do not match."
            )
    return new_edges