Problem hidden

SNGINT - Encode Integer

Given an integer N (0 ≤ N < 107), find the smallest positive integer M (M > 0) such that the product of digits of M equals N.

Input

The first line of input is T (the total number of test cases), followed by T (T < 10001) lines, each containing an integer N.

Output

For each integer N, output in a separate line the integer M, or -1 (if encoding is not possible).

Example

Input:
3
24
5
11

Output:
38
5
-1

Adicionado por:AvmnuSng
Data:2014-02-03
Tempo limite:0.100s-0.5s
Tamanho do fonte:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Linguagem permitida:Todas exceto: ASM64 CLOJURE ERL FSHARP GOSU PERL6 PY_NBC SCALA TCL
Origem:Abhimanyu Singh
My Problems
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.