An old bill was found among a grandfather's papers:
72 turkeys $_679_
The number obviously represented the total price of those turkeys, but its first and last digits are faded and illegible, so they are shown here as blanks (written _). What are the two faded digits, and what was the price of a single turkey?
We want a program that solves a general version of this problem:
N turkeys $_XYZ_
The number of turkeys N satisfies 1 <= N <= 99. The total price is originally a five-digit number, but only the middle three digits X, Y, and Z are still readable. Assume the first digit is nonzero, the price of one turkey is a whole number of dollars, and every turkey costs the same.
Given N, X, Y, and Z, determine the two faded digits and the original total price. If several total prices are possible, choose the most expensive one: report the two faded digits and the corresponding (maximum) price per turkey.
The first line contains the number of test cases T.
Each test case consists of two lines. The first line contains an integer N (0 < N < 100), the number of turkeys. The second line contains the three readable middle digits X, Y, and Z of the total price $_XYZ_, separated by single spaces.
Print one line for each test case.
If at least one valid total price exists, print the first faded digit, the last faded digit, and the maximum price per turkey, separated by single spaces. If no valid total price exists, print a single 0.