A. Ambagaata
time limit per test
4 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Anthanaa asas tha QWARTY kaabaard.

Anthonio (also known as Anthanaa) thinks it is funny to replace all vowels with the letter 'a'. When he types, he consistently replaces any 'a', 'e', 'i', 'o', 'u' with an 'a'. Any 'y' is either kept or replaced by an 'a' arbitrarily with no consistency.

You are given a dictionary of words of lowercase letters and a list of messages by Anthonio with only lowercase letters and spaces. Each word in the dictionary contains the letter 'y' at most four times.

Determine for each message whether the message is possibly consistent with the dictionary, and if so, whether it is ambiguous. If the message is consistent with the dictionary and not ambiguous, reconstruct Anthonio's intended message.

Input

The input consists of:

  • One line with two integers $$$n$$$ and $$$q$$$ ($$$1\leq n\leq {50\,000}$$$, $$$1\leq q\leq {10^3}$$$), the number of words in the dictionary and the number of messages you need to analyze.
  • $$$n$$$ lines, each with a string $$$w$$$ ($$$1 \leq |w| \leq {100}$$$), a word in the dictionary. Each word in the dictionary only consists of lowercase English letters (a-z), at most four of which are 'y'.
  • $$$q$$$ lines, each with an integer $$$m$$$ ($$$1 \leq m \leq {10^5}$$$), followed by $$$m$$$ strings $$$s$$$ ($$$1 \leq |s| \leq {100}$$$), describing a message. Each word in the messages only consists of lowercase English letters (a-z), at most four of which are 'y', and the vowels 'e', 'i', 'o', and 'u' do not occur.
All words in the dictionary are distinct. The total number of letters in the $$$n$$$ words in the dictionary is at most $$${2 \cdot 10^5}$$$. The total number of letters in the $$$q$$$ messages is at most $$${5 \cdot 10^5}$$$.
Output

For each message, if there is a unique message consisting of words in the dictionary that Anthonio could have meant, output "possible" followed by Anthonio's intended message. Otherwise, if there are multiple messages that Anthonio could have meant, output "ambiguous". Otherwise, output "impossible".

Examples
Input
7 3
hello
world
i
have
a
yoyo
lmao
2 halla warld
4 a hava a yaya
2 aaay lmaa
Output
possible hello world
ambiguous
impossible
Input
3 3
aayayy
ayyaay
yyyyaa
1 ayaaay
1 ayaaya
1 aayaay
Output
possible ayyaay
impossible
ambiguous