1. JAVA, Evgeni Pavlidis

/**
* ACM programming Contest WS 08/09
* UVa Status: accepted
* Run Time: 0.000
* @author Evgeni Pavlidis evgenipavlidis@yahoo.de
*/
#include <stdio.h>
#include <string.h>

#define MAX 100000

int number[MAX];



int main()
{
int cases,caseNumber, d,n,pos,j;
scanf("%d\n", &cases);
for(caseNumber = 1; caseNumber <= cases; caseNumber++)
{
pos = 0;
scanf("%d\n", &n);
if(n==1)
{
printf("1\n");
continue;
}

for(d=9; d > 1; d--)
if(n%d == 0)
{
n /= d;
number[pos++] = d;
d = 9;
}

if(n != 1)
printf("-1");
else
for(j=pos-1; j >= 0; j--)
printf("%d", number[j]);

printf("\n");
}
return 0;
}