P2462 [SDOI2007] Game

Background

# Description Xiao Mumu and Xiao Dengzi are two smart kids who started learning English when they were five. Their English teacher taught them a very simple game. The teacher gave them a list of English words, all in lowercase and without special symbols. The word list is as follows: ab arc arco bar bran carbon carbons cobra crab crayon narc They are asked to find a word chain from the list. The rules of the chain are: 1. Every letter that appears in the previous word must also appear in the next word, and the number of occurrences of each letter in the next word must be at least that in the previous word. 2. The length of the next word must be exactly 1 more than the length of the previous word. For the above example, a valid chain is: ab bar crab cobra carbon carbons Whoever makes a longer chain wins. Xiao Mumu definitely does not want to lose, so he comes to you and pesters you until you help him just to avoid being bothered. As for Xiao Dengzi? Maybe he went to find Guo Daniu. Hehe, a programming contest between you and Guo Daniu? Good luck!

Description

Xiao Mumu and Xiao Dengzi are two smart kids who started learning English when they were five. Their English teacher taught them a very simple game. The teacher gave them a list of English words, all in lowercase and without special symbols. The word list is as follows: ab arc arco bar bran carbon carbons cobra crab crayon narc They are asked to find a word chain from the list. The rules of the chain are: 1. Every letter that appears in the previous word must also appear in the next word, and the number of occurrences of each letter in the next word must be at least that in the previous word. 2. The length of the next word must be exactly 1 more than the length of the previous word. For the above example, a valid chain is: ab bar crab cobra carbon carbons Whoever makes a longer chain wins. Xiao Mumu definitely does not want to lose, so he comes to you and pesters you until you help him just to avoid being bothered. As for Xiao Dengzi? Maybe he went to find Guo Daniu. Hehe, a programming contest between you and Guo Daniu? Good luck! # Description

Input Format

The first line contains an integer $n$ ($1 \le n \le 10000$). Each of the next $n$ lines contains one word, with length at most $100$.

Output Format

On the first line, output the maximum chain length $ans$. On each of the next $ans$ lines, output one word representing your chain.

Explanation/Hint

Translated by ChatGPT 5