Little Ivica solves crossword puzzles every day. In case you haven't seen one, a crossword puzzle starts
on a grid of
Ivica's sister has a strange habit of looking at crosswords Ivica has finished solving, and finding the
lexicographically smallest word in it. She only considers words at least
Write a program that, given a crossword puzzle, finds that word.
Input Specification
The first line contains two integers
Each of the following
The input will be such that a solution will always exist.
Output Specification
Output the lexicographically smallest word in the crossword.
Sample Input 1
4 4
luka
o#a#
kula
i#a#
Sample Output 1
kala
Sample Input 2
4 4
luka
o#a#
kula
i#as
Sample Output 2
as
Sample Input 3
4 5
adaca
da##b
abb#b
abbac
Sample Output 3
abb
Comments
why wouldn't the answer be "bb" for sample 3
"abb" is lexicographically less than "bb" because it starts with 'a'
Oh I didn't realize that it had more priority than the length, thanks