Codeforces Round 530 (Div. 2)
C
Postcard
Codeforces
1200
原题
← BD →
翻译中…

Andrey received a postcard from Irina. It contained only the words "Hello, Andrey!", and a strange string consisting of lowercase Latin letters, snowflakes and candy canes. Andrey thought that this string is an encrypted message, and decided to decrypt it.

翻译中…

Andrey noticed that snowflakes and candy canes always stand after the letters, so he supposed that the message was encrypted as follows. Candy cane means that the letter before it can be removed, or can be left. A snowflake means that the letter before it can be removed, left, or repeated several times.

翻译中…

For example, consider the following string:

翻译中…

image

翻译中…

This string can encode the message «happynewyear». For this, candy canes and snowflakes should be used as follows:

翻译中…
  • candy cane 1: remove the letter w,
  • snowflake 1: repeat the letter p twice,
  • candy cane 2: leave the letter n,
  • snowflake 2: remove the letter w,
  • snowflake 3: leave the letter e.
翻译中…

image

翻译中…

Please note that the same string can encode different messages. For example, the string above can encode «hayewyar», «happpppynewwwwwyear», and other messages.

翻译中…

Andrey knows that messages from Irina usually have a length of $k$ letters. Help him to find out if a given string can encode a message of $k$ letters, and if so, give an example of such a message.

翻译中…

Input

翻译中…

The first line contains the string received in the postcard. The string consists only of lowercase Latin letters, as well as the characters «*» and «?», meaning snowflake and candy cone, respectively. These characters can only appear immediately after the letter. The length of the string does not exceed $200$.

翻译中…

The second line contains an integer number $k$ ($1 \leq k \leq 200$), the required message length.

翻译中…

Output

翻译中…

Print any message of length $k$ that the given string can encode, or «Impossible» if such a message does not exist.

翻译中…

样例

Input #1
hw?ap*yn?eww*ye*ar
12
Output #1
happynewyear
InputCopy OutputCopy
Input #2
ab?a
2
Output #2
aa
InputCopy OutputCopy
Input #3
ab?a
3
Output #3
aba
InputCopy OutputCopy
Input #4
ababb
5
Output #4
ababb
InputCopy OutputCopy
Input #5
ab?a
1
Output #5
Impossible
InputCopy OutputCopy
题目信息
题号
1099C
时间限制
1 s
内存限制
256 MB
标签
构造
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。