Good Numbers
Easy Accuracy: 40.12% Submissions: 339 Points: 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
 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.