LogiQuest

100. Longest Common Prefix

EasyString

Print the longest common prefix of n words, or - if it is empty.

Input format

Line 1: n Next n lines: one word each

Output format

The common prefix, or -

Example 1

Input

3
flower
flow
flight

Output

fl

Example 2

Input

3
dog
racecar
car

Output

-

Constraints

1 ≤ n ≤ 1000

Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.

Loading the MyLoginn IDE…