#agc061d. [agc061_d]Almost Multiplication Table
[agc061_d]Almost Multiplication Table
Problem Statement
There are positive integers , and an positive integer matrix . For two (strictly) increasing positive integer sequences and , we define the penalty as $\\max_{1 \\leq i \\leq N, 1 \\leq j \\leq M} |X_i Y_j - A_{i, j}|$.
Find two (strictly) increasing positive integer sequences and such that is the smallest possible.
Constraints
- (, )
- All values in the input are integers.
Input
Input is given from Standard Input in the following format:
Output
Output your answer in the following format:
Here, is the smallest possible penalty and the following conditions should be satisfied:
- should be equal to .
- ().
- ().
- ().
- ().
One can show that there is an optimal solution satisfying the last two conditions.
Sample Input 1
1 1
853922530
Sample Output 1
0
31415
27182
Sample Input 2
3 3
4 4 4
4 4 4
4 4 4
Sample Output 2
5
1 2 3
1 2 3
Sample Input 3
3 4
4674 7356 86312 100327
8737 11831 145034 167690
47432 66105 809393 936462
Sample Output 3
357
129 216 1208
39 55 670 775