1. Longest common prefix of codes
mediumThe exam cell has a list of n course codes, such as CS101, CS102 and CS110. To print one heading for the list, they need the longest starting part that every code shares. For these three codes it is CS1.
Print that shared start. If the codes do not even share the first character, print NONE.
Input: The first line has one integer n. The second line has n codes separated by spaces.
Output: One line: the longest shared start, or NONE.
Limits: 1 ≤ n ≤ 10^4 · 1 ≤ length of each code ≤ 100 · Codes have only capital letters A–Z and digits 0–9
Example 1
Input
3 CS101 CS102 CS110
Output
CS1
All three codes start with CS1. The fourth characters 0, 0 and 1 differ.
Example 2
Input
3 ME201 EE201 CE201
Output
NONE
The first characters already differ.