def METHOD_NAME(sa: Sequence[T], sb: Sequence[T], key):
    def make_dict(s: Sequence[T]) -> Dict[str, List[T]]:
        res: Dict[str, List[T]] = {}
        for a in s:
            k = key(a)
            ll = res.get(k, None)
            if ll is None:
                ll = []
                res[k] = ll
            ll.append(a)
        return res
    da = make_dict(sa)
    db = make_dict(sb)
    ka = set(da.keys())
    kb = set(db.keys())
    onlya: Set[T] = set()
    common: Set[T] = set()
    onlyb: Set[T] = set()
    for k in ka.union(kb):
        la = da.get(k, [])
        lb = db.get(k, [])
        common.update(la[:min(len(la), len(lb))])
        if len(la) > len(lb):
            onlya.update(la[len(lb):])
        if len(lb) > len(la):
            onlyb.update(lb[len(la):])
    return onlya, common, onlyb