Digit String
题号:NC237411
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述


There is a digit string s of length n. Define f(x) be the number of times digit x appears in the string s.
You can arbitrarily modify each character of s into any digit so that the maximum value of f(x) is less than or equal to m. Define s' as the modified string, then the cost of modification is . Minimize the cost and output a lexicographically smallest s'.
A digit string only contains characters from 0 to 9.

输入描述:

This problem contains multiple test cases.
The first line contains an integer T indicating the number of test cases.
For each test case, the first line contains two integers n, m (). It's guaranteed that there always is a solution.
The second line contains a digit string s of length n.
It's guaranteed that .

输出描述:

For each test case, output two lines.
The first line contains an integer, the minimum cost.
The second line is a digit string s' of length n, which is the lexicographically smallest solution.

示例1

输入

复制
2
6 2
122223
6 2
122333

输出

复制
2
112233
1
122334