27 1 s 128 MB
You are given an integer N. Find the smallest positive integer X such that the product of its digits (in decimal notation) is equal to N. Print the number of digits in X, or print -1 if such a number does not exist.
The input consists of T test cases. The number of test cases T is given in the first line of the input.
Print exactly one line for each test case.
6 1 10 26 100 2520 864
1 2 -1 3 4 4