1. 

/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #993 (Product of digits)
* Link: http://icpcres.ecs.baylor.edu/onlinejudge/index.php?option=com_onlinejudge&Itemid=8&category=11&page=show_problem&problem=934
*
* @author Fabian Seidl
* @author Marcel Sachse
* @version 1.0, 22/04/2009
*
* Status : Accepted
* Runtime: 0.170
*/

import java.io.*;
import java.util.Scanner;



public class Main {

public static void main(String[] args) throws Exception
{
BufferedInputStream bInput = new BufferedInputStream(System.in);
Scanner scanner = new Scanner(bInput);

Writer out = new BufferedWriter(new PrintWriter(System.out));

int dataSets = scanner.nextInt();

for(int i=0;i<dataSets;i++)
{
int n = scanner.nextInt();
String q = "";

if(n==1) q = "1";
else
for(int j = 9;n>1 && j>1;j--)
{
while(n > 1 && n % j == 0)
{
n /= j;
q = j + q;
}
}

if(n==1) out.write(q + "\n");
else out.write("-1\n");

}

out.close();

}

}