Numeral systems
시간 제한3초메모리 제한1024 MB
각 K와 D에 대해, 십진값에서 D를 뺀 수가 십육진값을 나누어떨어지게 하는 K자리 표기를 모두 찾는다.
문제
Khodislav has learned that apart from the decimal numeral system, there exist other systems, such as the hexadecimal system. He is curious about the connection of the values of the same notation in these two systems. For instance, can a sequence of digits have its hexadecimal value divisible by its decimal value? Will anything change if we subtract a specified number from the decimal value of this notation?
A notation is a sequence of digits. Digits from 0 through 9 can be used in a notation: they belong both to the decimal and to the hexadecimal systems. A notation of a number cannot begin with the digit 0. The decimal value of a notation is the number resulting from interpreting the notation as a decimal number. The hexadecimal value of a notation is the number resulting from interpreting the notation as a hexadecimal number.
입력
The first line contains an integer --- the number of tests in the file (). It is followed by tests, one per line.
For each test, two integers are provided: --- the number of digits in the notation and --- the number to be subtracted from the decimal value (, ).
출력
For each test, find all required notations. Notations are sequences of digits without leading zeroes, with the value of in the decimal system and the value of in the hexadecimal system, for which and is divisible by without remainder.
The answers to each test are printed in a single line. First, print the number of the found notations, followed by all found notations in the ascending order, separated by spaces.
힌트
In the first test, the notation 37950 means in the decimal system and in the hexadecimal system. We can see that is divisible by without remainder. Identically, for the notation 24990, is divisible by , and for the notation 12510, is divisible by .