408456: GYM103134 A Kobus hates sweepstakes

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Kobus hates sweepstakestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

In the middle of the year we held the Selective IME-USP, a contest to selects which teams will represent USP Butantã in official competitions. In this test, it is clear that the people at MaratonUSP are very competitive, after all, we are a competitive programming group.

In this edition, the tests are being carried out individually, and no longer in teams of 3 people. After the end of the competition, with the general score already available, Kobus realized that she drew first in the tryouts with $$$N$$$ other participants, who are from POLI. As we accept nothing less than the best ─ even more so against polytechnics ─ she wants to come first. But, unfortunately, the tiebreaker criterion is a draw.

To carry out the draw, Nathan will take the string $$$ A = abcdefghijklmnopqrstuvwxyz $$$, which represents the alphabet, and change some letters of place, obtaining a new string $$$ A'$$$. In other words, $$$A'$$$ is a permutation of $$$A$$$. Using this new string as alphabetical order, Nathan will then sort the names, and the name that comes first is the winner.

Kobus has access to the secret laboratory where Nathan studies and, with that, she can change $$$ A '$$$. Help Kobus to come first or say if that is impossible.

Input

The first line contains an integer $$$N$$$ $$$(1 \leq N \leq 1000)$$$ ─ the number of participants who tied with Kobus in the first place.

Each of the next $$$ N $$$ lines contains a lower character string $$$ s_i $$$ $$$ (1 \leq | s_i | \leq 100) $$$ ─ the name of the $$$ i $$$-th participant tied with Kobus. It is guaranteed that everyone participating in the competition has different names.

Output

Print a string $$$ A '$$$ $$$ (| A' | = 26) $$$ which is a permutation of $$$ A $$$ that makes Kobus come first. If multiple answers exist, print any one.

If it is not possible for Kobus to come first, print "sem chance" (without quotes).

ExamplesInput
3
lamarca
kob
grabriel
Output
sem chance
Input
5
fabiana
marcos
roberto
julia
maquiesperto
Output
abcdekghijflmnopqrstuvwxyz
Note

Sorting a word list uses the relative order between two words. We can call this relative order a lexicographic order. A word $$$ x_1, x_2, \dots, x_a $$$ is lexicographically smaller than the word $$$ y_1, y_2, \dots, y_b $$$ if one of the two conditions below is valid:

  • $$$ a < b $$$ e $$$ x_1 = y_1, x_2 = y_2, \dots, x_a = y_a $$$, that is, the first word is a prefix to the second; or if
  • there is a position $$$j$$$ $$$(1 \leq j \leq min(a, b))$$$, such that $$$x_1=y_1,x_2=y_2,\dots, x_{j-1}=y_{j- 1}$$$ and $$$x_j < y_j$$$, that is, in the first position where the words differ, the letter of the first word in that position is smaller than the letter of the second word in that same position (the letter of the first word comes before in the alphabet than the letter of the second word).

For example, let the list of words be given by $$$ \{aaa, aa, ba \} $$$. If the alphabet is $$$ abcd ... z $$$, then the ordered list is $$$ \{aa, aaa, ba \} $$$. However, if the alphabet is $$$ bacd ... z $$$ then the ordered list becomes $$$ \{ba, aa, aaa \} $$$.

加入题单

上一题 下一题 算法标签: