K. King's Challenge
time limit per test
10 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
3
10 4
1000 3
100001 2
Output
504
97002
00001