Patterns

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

Input consists of several cases. Each case starts with nn, followed by nn words, all of the same length, which will be between 1 and 10001000. You can assume 1n10001 \le n \le 1000, and that the words only consist of lowercase letters.

Output

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.”.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T12:04:27.317Z

© Jutge.org, 2006–2026.
https://jutge.org