SP200 MONODIG - Monodigital Representations

Description

Let _K_ be a decimal digit different from . We say that an arithmetic expression is a **K-representation of the integer X** if a value of this expression is X and if it contains only numbers composed of a digit K. (All the numbers are of course decimal). The following arithmetical operations are allowed in the expression: addition, subtraction, multiplication and division. Round brackets are allowed too. Division may appear only when a dividend is a multiple of a divisor.

Input Format

The number of test cases t is in the first line of input, then t test cases follow separated by an empty line. The first line of each test case contains digit _K_, _K_ is en element of {_1,...,9_}. The second line contains number n, _1

Output Format

The output for each test case composes of _n_ lines. The _i-_th line should contain: - exactly one number which is the minimal length of _K_-representation of a $ _{i} $ , assuming that such a representation of length not grater then 8 exists, - one word NO, if the minimal length of the _K_-representation of the number _a_ $ _{i} $ is grater than 8.