No.2715 Unique Chimatagram
Problem Statement
For strings $S, T$ consisting of lowercase English letters, $T$ is called a chimatagram of $S$ if $T$ can be obtained by performing the following operations on $S$ in order:
- Append $1$ lowercase English letter of your choice to the end of $S$.
- Rearrange the characters of $S$ in any order of your choice.
You are given strings $S_1, \ldots, S_N$ consisting of lowercase English letters. Determine whether there exists a string $T$ of lowercase English letters satisfying the following condition, and if it exists, print $1$ such $T$:
- (Condition) There exists exactly one $1 \leq i \leq N$ such that $T$ is a chimatagram of $S_i$.
Constraints
- $1 \leq N \leq 10^3$
- $N$ is an integer
- $S_i$ is a string of length between $1$ and $10$, inclusive, consisting only of lowercase English letters
Input
The input is given from standard input in the following format.
$N$ $S_1$ $\vdots$ $S_N$
Output
If there exists a string $T$ of lowercase English letters satisfying the condition, print $1$ such $T$. If it does not exist, print -1.
Print a newline at the end.
Sample
Sample 1
Input
3 rock scissors paper
Output
appear
appear can be made by appending a to paper and rearranging, so it is a chimatagram of paper. On the other hand, it can be proved that appear is not a chimatagram of rock or scissors.
Sample 2
Input
2 file life
Output
-1
For example, flier is a chimatagram of file, but it is also a chimatagram of life, so it does not satisfy the condition.
Sample 3
Input
5 one plus one equals two
Output
pulse
The strings $S_i$ may contain identical strings.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
hamamu