#000143

BubbleSecretary

The big boss has a new secretary who is rather clumsy and computer illiterate. Once, the boss asked her secretary to make n copies of some text, which contained a very important alphanumeric code of length m. The poor secretary has retyped the whole text n times. A bit later, in each copy she has found one mistyped character (not necessarily a different one). Unfortunately, each time it was one of the characters in the code. To make things worse, the secretary has lost the original text, so the correction cannot be done easily. Please help the secretary to keep her job and reconstruct the correct code if reconstruction is possible.



InputFirst line contains two positive integer numbers n and m, separated by a space, with n  ≤  100, m  ≤  40. In each of the next n lines, there is a sequence of m characters, which are either capital English letters or digits.


OutputIf there are several sequences that differ from each of the input sequences in exactly one character, the output should contain the word “AMBIGUOUS”. If there is no such sequence (meaning that the secretary did not even count mistakes correctly), the output should contain the word “IMPOSSIBLE”. If there is only one such sequence, it is considered correct and
the output should contain that sequence.


Input:
3 9
12305A7Q9
12375A7Q9
12375A7Q9


Output:
AMBIGUOUS

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.