{"problem":{"name":"M. Forgotten Spell","description":{"content":"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 resto","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10175M"},"statements":[{"statement_type":"Markdown","content":"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.\n\nThree strings of the same length n (1 ≤ n ≤ 200000) are given in the input. They consist of lowercase Latin letters.\n\nIf such a situation is not possible, output «_Impossible_».\n\nIf there are several spells satisfying the conditions, output «_Ambiguous_».\n\nFinally, if the forgotten spell is the only one possible, output it.\n\n## Input\n\nThree strings of the same length n (1 ≤ n ≤ 200000) are given in the input. They consist of lowercase Latin letters.\n\n## Output\n\nIf 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.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ with $ 1 \\leq n \\leq 200000 $.  \nLet $ s_1, s_2, s_3 \\in \\Sigma^n $ be three input strings over the alphabet $ \\Sigma = \\{a, b, \\dots, z\\} $.  \nLet $ x \\in \\Sigma^n $ be the target spell.\n\n**Constraints**  \nFor each $ i \\in \\{1,2,3\\} $, the Hamming distance satisfies $ d_H(s_i, x) \\leq 1 $.\n\n**Objective**  \nDetermine the set $ X = \\{ x \\in \\Sigma^n \\mid \\forall i \\in \\{1,2,3\\},\\ d_H(s_i, x) \\leq 1 \\} $:  \n- If $ |X| = 0 $, output \"Impossible\".  \n- If $ |X| > 1 $, output \"Ambiguous\".  \n- If $ |X| = 1 $, output the unique $ x \\in X $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10175M","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}