WOBURN CCC PRACTICE

CIRCULAR NUMBERS

INPUT FILE: circ.in
OUTPUT FILE: circ.out

An (XY, D) � CIRCULAR NUMBER is a number whose last two digits are X and Y, and multiplication of the number by the single digit D is equivalent to moving the last two digits (XY) to the beginning of the number. For example, the number 132832080200501253 is a (53, 4) � CIRCULAR NUMBER because 132832080200501253 * 4 = 531328320802005012. Write a program that asks for two-digit number XY and a single digit D, and prints the SMALLEST (XY, D) � CIRCULAR NUMBER or prints a message NONE if none exists. It is guaranteed that your number will not exceed 255 digits.

INPUT
An integer number, N, indicating the total number of cases. On each of the next N lines are the two-digit number XY and the single digit D, separated by a space.

OUTPUT
The smallest circular number (if one exists with less than 255 digits) that satisfies the given condition; otherwise output the message NONE.

SAMPLE DATA

Input file

1
53 4

Output file

132832080200501253
Downloader failed! Response object 006~ASP 0159~Buffering Off~Buffering must be on.