def list_visitor(state, components):
    """Return a list of lists to represent the partition.

    Examples
    ========

    >>> states = multiset_partitions_taocp([1, 2, 1])
    >>> s = next(states)
    >>> list_visitor(s, 'abc')  # for multiset 'a b b c'
    [['a', 'b', 'b', 'c']]
    >>> s = next(states)
    >>> list_visitor(s, [1, 2, 3])  # for multiset '1 2 2 3
    [[1, 2, 2], [3]]

    """
    f, lpart, pstack = state
    partition = []
    for i in range(lpart + 1):
        part = []
        for ps in pstack[f[i]:f[i + 1]]:
            if ps.v > 0:
                part.extend([components[ps.c]] * ps.v)
        partition.append(part)
    return partition
