Both winning BAPC and publishing research papers is a team effort. And every member of the team wants to be appreciated.
Every research paper has a list of authors at the top. Each author is listed using their full name, which might consist of several parts.
To avoid arguments about the order of names, your team decided to just order the list of names in the following way:
However, your team already submitted the draft for your paper before you came up with this idea.
You are given the list of author as presented in the draft. Is it possible to pick name parts in a way that the list of authors in the draft is sorted?
The input consists of:
If it is possible to select a name part for each author such that the list is sorted, output for each author the selected name part. Otherwise, output "impossible".
If there are multiple valid solutions, you may output any one of them.
62 Maria Douglas3 Ozzy Levi Carpenter3 Quentin Aaron Potter2 Christy Iglesias2 Mo Mansur3 Sam Marlon Scully
impossible
42 Maria Douglas3 Ozzy Levi Carpenter3 Quentin Aaron Potter3 Sam Marlon Scully
Maria Ozzy Potter Scully
31 Sam1 Sam1 Sam
Sam Sam Sam
| Name |
|---|


