#d2743. 漂亮数

漂亮数

Beautiful Number

Problem Description

You are given a number XX of length nn, whose decimal digits are a1,a2,…,ana_1, a_2, \dots, a_n (ordered from left to right). You are also given an integer kk.

You need to construct the smallest number YY satisfying the following two conditions:

  • For every position ii with 1≤i≤m−k1 \le i \le m - k, we have bi=bi+kb_i = b_{i+k};
  • X≤YX \le Y,

where b1,b2,…,bmb_1, b_2, \dots, b_m are the digits of YY from left to right.

Input Format

The first line contains two integers n,kn, k, where 2≤n≤2000002 \leq n \leq 200000 and 1≤k<n1 \leq k < n.

The second line contains XX, written as a string of nn digits a1a2…ana_1 a_2 \dots a_n.

Output Format

The first line contains mm, the length of YY.

The second line contains the smallest valid number YY, written as the digits b1b2…bmb_1 b_2 \dots b_m.

Sample Input

3 2
353

Sample Output

3
353