cho.sh
Notes
Loading...

Group Word Reconstruction

Time limit

2s

Memory limit

128 MB

Problem

A word is a group word if, for every lowercase letter, all occurrences of that letter form one contiguous block. For example, aabbbcc is a group word, while abca is not because the letter a is split into two blocks.

One group word was cut into several pieces, and the pieces are given in arbitrary order. Use every piece exactly once and find the original group word that can be reconstructed.

Input

The first line contains the number of pieces N. N is a positive integer not greater than 50.

Each of the next N lines contains one piece. Each piece is a lowercase English string of length at most 20.

Output

If exactly one original group word is possible, output that word.

If multiple words are possible, output -_-. If no ordering can make a group word, output gg.