The task is to find the smallest number with given sum of digits as s and number of digits as d.
Expected Time Complexity: O(d)
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consist of a single line containing two space separated integers s and d, where s is digit sum and d is number of digits.
Corresponding to each test case, in a new line, print the smallest number if possible, else print -1.
1 ≤ T ≤ 100
1 ≤ s ≤ 100
1 ≤ d ≤ 6
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.