CF120H.Brevity is Soul of Wit

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

As we communicate, we learn much new information. However, the process of communication takes too much time. It becomes clear if we look at the words we use in our everyday speech.

We can list many simple words consisting of many letters: "information", "technologies", "university", "construction", "conservatoire", "refrigerator", "stopwatch", "windowsill", "electricity", "government" and so on. Of course, we can continue listing those words ad infinitum.

Fortunately, the solution for that problem has been found. To make our speech clear and brief, we should replace the initial words with those that resemble them but are much shorter. This idea hasn't been brought into life yet, that's why you are chosen to improve the situation.

Let's consider the following formal model of transforming words: we shall assume that one can use nn words in a chat. For each words we shall introduce a notion of its shorter variant. We shall define shorter variant of an arbitrary word ss as such word tt , that meets the following conditions:

  • it occurs in ss as a subsequence,
  • its length ranges from one to four characters.

In other words, the word tt consists at least of one and at most of four characters that occur in the same order in the word ss . Note that those characters do not necessarily follow in ss immediately one after another. You are allowed not to shorten the initial word if its length does not exceed four characters.

You are given a list of nn different words. Your task is to find a set of their shortened variants. The shortened variants of all words from the list should be different.

输入格式

The first line of the input file contains the only integer nn (1<=n<=200)(1<=n<=200) . Then nn lines contain a set of different non-empty words that consist of lowercase Latin letters. The length of each word does not exceed 1010 characters.

输出格式

If the solution exists, print in the output file exactly nn lines, where the ii -th line represents the shortened variant of the ii -th word from the initial set. If there are several variants to solve the problem, print any of them. If there is no solution, print -1.

输入输出样例

  • 输入#1

    6
    privet
    spasibo
    codeforces
    java
    marmelad
    normalno
    

    输出#1

    pret
    sps
    cdfs
    java
    mama
    norm
    
  • 输入#2

    5
    aaa
    aa
    a
    aaaa
    aaaaa
    

    输出#2

    -1
    
首页