 Good Numbers
Submissions: 272   Accuracy: 44.47%   Difficulty: Easy   Marks: 2

Given two positive integers L & R  and a digit D, print out all the good numbers in the range [L , R], which do not contain the digit D. A number is a good number if its every digit is larger than the sum of digits which are on the right side of that digit.
For example:
9620  is good as (2 > 0, 6 > 2+0, 9 > 6+2+0)

Input
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow.
The first line of each test case contains an integer D.
The second line of each test case contains two space separated integers L & , denoting range
[L , R].

Output
Print out all the good numbers in range the [L , R] which do not contain the digit D .
If no such numbers exist, then print  -1.

Constraints
1 <= T <= 100
0 <= D <= 9
0 <= L <=R<=2*10^4

Examples

Input
3
4
100 700
2
8467 14801
1
2995 4937

Output
210 310 320 510 520 521 530 531 610 620 621 630 631 632 650
8510 8610 9310 9410 9430 9510 9530 9610 9710
-1

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

Author: Rohan Malhotra

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.