欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1099C.Postcard
Postcard
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:

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
ptwice, - candy cane 2: leave the letter
n, - snowflake 2: remove the letter
w, - snowflake 3: leave the letter
e.

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 letters. Help him to find out if a given string can encode a message of 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 .
The second line contains an integer number (), the required message length.
Output
Print any message of length that the given string can encode, or «Impossible» if such a message does not exist.
Samples
hw?ap*yn?eww*ye*ar
12
happynewyear
ab?a
2
aa
ab?a
3
aba
ababb
5
ababb
ab?a
1
Impossible
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |