def to_multiset(token): 
    """ Creates a multiset from a string. A multiset is a set of tuples (c, n) where c is a character and n is a count of that character in the string."""
    counts = {}
    for ch in token:
        try:
            count = counts[ch]
        except KeyError:
            count = 0
        counts[ch] = count + 1
    multiset = set()
    for ch in counts:
        multiset.add((ch, counts[ch]))
    return frozenset(multiset)