Smallest number
Submissions: 5691   Accuracy:

35.14%

  Difficulty: Basic   Marks: 1

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)

Input:
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.

Output:
Corresponding to each test case, in a new line, print the smallest number if possible, else print -1.

Constraints:
1 ≤ T ≤ 100
1 ≤ s ≤ 100
1 ≤ d ≤ 6

Example:

Input
3
9 2
20 3
63 3

Output
18
299
-1

** For More Input/Output Examples Use 'Expected Output' option **

Author: rajatjha


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.