Digit multiplier
Submissions: 2515   Accuracy:

25.68%

  Difficulty: Medium   Marks: 4

Given a positive integer N, find the smallest number S such that the product of all the digits of S is equal to the number N.

Input
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains a positive integer N.

Output
Print out the number S. If there exists no such number, then print -1.

Constraints
1 <= T <= 200
1<= N <=109

Examples 

Input
2
100
26

Output
455
-1

** For More Input/Output Examples Use 'Expected Output' option **

Author: Rohan Malhotra


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.