def strip_right_above_below(chars):
    """Drop leading and trailing blank lines, and drop trailing spaces in each line"""

    lines_plus = chars.splitlines()

    lines = list(_.rstrip() for _ in lines_plus)

    while lines and not lines[0]:
        lines = lines[1:]
    while lines and not lines[-1]:
        lines = lines[:-1]

    chars = ""
    if lines:
        chars = "\n".join(lines) + "\n"

    return chars