405060: GYM101755 M Forgotten Spell
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
M. Forgotten Spelltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output
Three mages are trying to remember a spell. Each of them believes the spell is some string of length n and it is known that each of the mages is mistaken in at most one letter. It is required to restore the forgotten spell.
InputThree strings of the same length n (1 ≤ n ≤ 200000) are given in the input. They consist of lowercase Latin letters.
OutputIf such a situation is not possible, output «Impossible».
If there are several spells satisfying the conditions, output «Ambiguous».
Finally, if the forgotten spell is the only one possible, output it.
ExamplesInputaabOutput
aca
daa
aaaInput
abcOutput
aca
abc
AmbiguousInput
abcdeOutput
fghij
klmno
Impossible