CF599B Spongebob and Joke

题目描述

当派大星去购物时,海绵宝宝决定戏弄一下他的朋友。调皮的海绵宝宝翻看了派大星的个人物品,找到了一个长度为 $ m $ 的序列 $ a_{1},a_{2},...,a_{m} $,由整数 $ 1 $ 到 $ n $ 组成,不一定是不同的。然后,他选择了一个长度为 $ n $ 的序列 $ f_{1},f_{2},...,f_{n} $,对于每个数字 $ a_{i} $,得到数字 $ b_{i}=f_{a_i} $。为了完成这个恶作剧,他将初始序列 $ a_{i} $ 扔掉了。 难以想象派大星从购物回来后有多伤心!海绵宝宝马上对自己的所作所为感到非常抱歉,他现在正在尝试恢复原始序列。请你帮助他完成这个任务或确定这是否不可能。 **形式化题意**:给你一个长度为 $n$ 的数组 $f$ 和一个长度为 $m$ 的数组 $b$,并规定 $f_{a_i} = b_i$,请尝试恢复出原数组。如果有多种可能,输出 `Ambiguity`,如果无法还原,输出 `Impossible`。

输入格式

输入的第一行包含两个整数 $ n $ 和 $ m $($ 1

输出格式

如果存在正好一个序列 $ a_{i} $,使得对于所有 $ i $ 从 $ 1 $ 到 $ m $ 都满足 $ b_{i}=f_{a_i} $,则输出 `Possible`。然后打印 $ m $ 个整数 $ a_{1},a_{2},...,a_{m} $。 如果有多种可能,输出 `Ambiguity`,如果无法还原,输出 `Impossible`。

说明/提示

In the first sample $ 3 $ is replaced by $ 1 $ and vice versa, while $ 2 $ never changes. The answer exists and is unique. In the second sample all numbers are replaced by $ 1 $ , so it is impossible to unambiguously restore the original sequence. In the third sample $ f_{i}≠3 $ for all $ i $ , so no sequence $ a_{i} $ transforms into such $ b_{i} $ and we can say for sure that Spongebob has made a mistake.