Codeforces Global Round 1
H
Modest Substrings
Codeforces
3500
原题
← G→
翻译中…

You are given two integers $l$ and $r$.

翻译中…

Let's call an integer $x$ modest, if $l \le x \le r$.

翻译中…

Find a string of length $n$, consisting of digits, which has the largest possible number of substrings, which make a modest integer. Substring having leading zeros are not counted. If there are many answers, find lexicographically smallest one.

翻译中…

If some number occurs multiple times as a substring, then in the counting of the number of modest substrings it is counted multiple times as well.

翻译中…

Input

翻译中…

The first line contains one integer $l$ ($1 \le l \le 10^{800}$).

翻译中…

The second line contains one integer $r$ ($l \le r \le 10^{800}$).

翻译中…

The third line contains one integer $n$ ($1 \le n \le 2\,000$).

翻译中…

Output

翻译中…

In the first line, print the maximum possible number of modest substrings.

翻译中…

In the second line, print a string of length $n$ having exactly that number of modest substrings.

翻译中…

If there are multiple such strings, print the lexicographically smallest of them.

翻译中…

Note

翻译中…

In the first example, string «101» has modest substrings «1», «10», «1».

翻译中…

In the second example, string «111» has modest substrings «1» ($3$ times) and «11» ($2$ times).

翻译中…

样例

Input #1
1
10
3
Output #1
3
101
InputCopy OutputCopy
Input #2
1
11
3
Output #2
5
111
InputCopy OutputCopy
Input #3
12345
12346
6
Output #3
1
012345
InputCopy OutputCopy
题目信息
题号
1110H
时间限制
5 s
内存限制
1024 MB
标签
动态规划
字符串

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