Skip to content
UPEEC

Longest Common Prefix

Easy#strings· solved by 0 · time limit 2.0 s

Find the longest prefix shared by all nn words. Print -1 if there is none.

Input

nn, then nn lowercase words, one per line.

Output

The prefix or -1.

Constraints

1≤n≤10001 \le n \le 1000

Sample 1

Input

3
flower
flow
flight

Output

fl

Sample 2

Input

2
dog
car

Output

-1

Sign in or join free to run and submit your solution.