Canadian Computing Competition: 2001 Stage 1, Senior #5
Let
and
be two sequences of non-empty strings:

Let
be a positive integer. Does there exist a sequence of integers
such that
and
?
For example, if
and
, then the required sequence of integers is
giving
.
Input Specification
The first two lines of input will contain
and
respectively, and
. The next
lines contain in order the elements of
followed by the elements of
. Each string is at most
characters.
Output Specification
If a solution exists, print
on a line by itself, followed by the integer sequence in order, one element per line. Otherwise, print a single line containing No solution.
.
Sample Input 1
Copy
7
3
a
abaaa
ab
aaa
ab
b
Sample Output 1
Copy
4
2
1
1
3
Sample Input 2
Copy
10
3
abc
def
ghi
bcd
efg
hia
Sample Output 2
Copy
No solution.
Comments
tallinn
jeffthemonster200