def clean_word(word):
    import string
    return word.strip(string.punctuation)


with open('input.txt', 'r', encoding='utf-8') as f:
    lines = f.readlines()

with open('output.txt', 'w', encoding='utf-8') as f_out:
    for line_num, line in enumerate(lines, start=1):
        line = line.strip()

        if not line:
            continue

        words = line.split()

        # Очищаем первое слово
        first_clean = clean_word(words[0])
        first_len = len(first_clean)

        shorter_words = []
        for word in words[1:]:
            word_clean = clean_word(word)
            if word_clean and len(word_clean) < first_len:
                shorter_words.append(word)  # сохраняем исходное слово

        if shorter_words:
            f_out.write(f"{line_num} {' '.join(shorter_words)} {len(shorter_words)}\n")