During class, Bob's teacher wanted to try an interesting activity. He began by writing down a string of length containing only lowercase English letters, where is the number of students. Afterwards, he writes down each of the substrings of length , and gives one to each student. Bob and the rest of the class now need to find out what the original string could have been, or if the teacher has made a mistake.
Constraints
In all subtasks,
Subtask 1 [5%]
Subtask 2 [15%]
Subtask 3 [20%]
You only need to determine whether or not the teacher has made a mistake.
If there is a candidate for the original string, print out any string of length .
Subtask 4 [60%]
No additional constraints.
Input Specification
The first line contains two space-separated integers, and .
lines follow, each containing a string of length , one of the strings that the students received.
Output Specification
On one line, output any string that the teacher could have written down. If there are multiple such strings, then output any of them.
If there are no candidates for the original string, output -1
.
Sample Input 1
5 3
obl
rob
lem
pro
ble
Sample Output 1
problem
Sample Input 2
2 5
abcde
cdefa
Sample Output 2
-1
Comments