from typing import Counter


def chars(lines, coverage= 0.9995):
    """returns a string containing the most frequent types of characters
    which cover the strings in `lines`, ordered by their ranks.

    rank 0 is rigged to always be the whitespace.

    """
    char2freq = Counter(char for line in lines for char in line)
    total = sum(char2freq.values())
    cover = char2freq[" "]
    del char2freq[" "]
    chars = [" "]
    for char, freq in char2freq.most_common():
        if coverage <= (cover / total): break
        chars.append(char)
        cover += freq
    return "".join(chars)