#Lutece0431. Sum of Digits
Sum of Digits
Migrated from Lutece 431 Sum of Digits
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Petka thought of a positive integer n and reported to Chapaev the sum of its digits and the sum of its squared digits. Chapaev scratched his head and said: “Well, Petka, I won't find just your number, but I can find the smallest fitting number.” Can you do the same?
Input
The first line contains the number of test cases (no more than ). In each of the following tlines there are numbers and () separated by a space. They are the sum of digits and the sum of squared digits of the number .
Output
For each test case, output in a separate line the smallest fitting number n, or No solution
if there is no such number or if it contains more than digits.
Samples
4
9 81
12 9
6 10
7 9
9
No solution
1122
111112
Resources
NEERC 2008, Eastern subregion quarterfin