In this problem, we will say that a pattern is a string made up of
lowercase letters and symbols ‘?’, such as
“??me”. Each instance of ‘?’ must be replaced
by exactly one lowercase letter. We say that a string matches a pattern
if we can transform the pattern into the string by replacing the
question marks by the appropriate letters. For instance,
“same”, “some” and “home” all
match the pattern “??me”.
Given several words, can you find a pattern matched by all the words?
This pattern should contain the minimum number of ‘?’.
Input consists of several cases. Each case starts with , followed by words, all of the same length, which will be between 1 and . You can assume , and that the words only consist of lowercase letters.
For every case, print a pattern with the least amount of
‘?’ which is matched by all the words. If there is more
than one answer, print
“I should rethink this problem.”.
Input
3 same some home 2 cat gas 2 hello hello 2 xyz abc
Output
??me ?a? hello ???