Codeforces Beta Round 50
D
Writing a Song
Codeforces
2100
原题
← CE →
翻译中…

One of the Hedgehog and his friend's favorite entertainments is to take some sentence or a song and replace half of the words (sometimes even all of them) with each other's names.

翻译中…

The friend's birthday is approaching and the Hedgehog decided to make a special present to his friend: a very long song, where his name will be repeated many times. But try as he might, he can't write a decent song!

翻译中…

The problem is that the Hedgehog has already decided how long the resulting sentence should be (i.e. how many letters it should contain) and in which positions in the sentence the friend's name should occur, and it must not occur in any other position in the sentence. Besides, the Hedgehog decided to limit himself to using only the first $*K*$ letters of an English alphabet in this sentence (so it will be not even a sentence, but one long word).

翻译中…

The resulting problem is indeed quite complicated, that's why the Hedgehog asks you to help him and write a program that will make the desired word by the given name $*P*$, the length $*N*$ of the required word, the given positions of the occurrences of the name $*P*$ in the desired word and the alphabet's size $*K*$. Note that the occurrences of the name can overlap with each other.

翻译中…

Input

翻译中…

The first line contains numbers $*N*$ and $*K*$ which are the length of the required string and the alphabet size accordingly. The limitations are: $1 ≤ *N* ≤ 100$, $2 ≤ *K* ≤ 26$.

翻译中…

The second line contains the name $*P*$ which is a non-empty string whose length does not exceed $*N*$ characters. The string consists only of the first $*K*$ lowercase symbols of an English alphabet.

翻译中…

The third line contains the string of length $*N* - *length*(*P*) + 1$, consisting only of numbers zero and one. A number one in the $*i*$-th position means that an occurrence of the name $*P*$ should start from $*i*$-th position of the desired word, while a zero means that there is no occurrence starting here.

翻译中…

Output

翻译中…

Print the desired word $*S*$. If there are several answers, print any of them.

翻译中…

If there is no solution, then print "No solution".

翻译中…

样例

Input #1
5 2
aba
101
Output #1
ababa
InputCopy OutputCopy
Input #2
5 2
a
10001
Output #2
abbba
InputCopy OutputCopy
Input #3
6 2
abba
101
Output #3
No solution
InputCopy OutputCopy
题目信息
题号
54D
时间限制
2 s
内存限制
256 MB
标签
暴力
动态规划
字符串

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