Time limit
2s
Memory limit
128 MB
Given N distinct English words, find the two words that are most similar.
The similarity of two words is the length of the longest common prefix they share from the beginning. If they do not share a first character, this length is 0.
If more than one pair has the maximum prefix length, choose the pair whose first output word S appears earliest in the input. If there is still more than one such pair, choose the pair whose second output word T appears earliest in the input.
The first line contains N (2 <= N <= 20,000).
Each of the next N lines contains one distinct English word consisting only of lowercase letters. Each word has length at most 100.
Print S on the first line and T on the second line.
S and T must be different input words.