printРабочее место участника

printЗадачи

1629. Alphabet

Ограничения: время – 1s/2s, память – 32MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

A list of words written in some unknown alphabet was found. It is known, however, that these words are in alphabetic order. Write a program that will find the unique alphabetic ordering of used letters, or determine that no such ordering exists or that there is more than one possible solution.
Input
The first line of input contains a positive integer `N` (`N\ ≤\ 100`), the number of words. The following `N` lines contain the list of words found, one word per line. Each word consists of at most 10 lowercase letters.
Output
The first and only line of output should contain all letters in alphabetic order. If no such ordering exists, output ‘!’. If there is more than one solution, output ‘?’.

Sample Input 1

5
ula
uka
klua
kula
al

Sample Output 1

luka

Sample Input 2

4
jaja
baba
baja
beba

Sample Output 2

!

Sample Input 3

3
marko
darko
zarko

Sample Output 3

?
Source: COCI 2010/2011, contest #6
loading