#include <iostream> int factor[4] = {2,3,5,7};//2,3,4,5,6,7,8,9 int dim[4] = {0}; int main() { int t,N; // freopen("1.txt","r",stdin); scanf("%d",&t); while (t--) { scanf("%d",&N); if (N == 0 || N == 1) { printf("%d/n",N); continue;} memset(dim,0,sizeof(dim)); for (int i = 0; i < 4;++i) while (N % factor[i] == 0) { N /= factor[i]; dim[i]++;} if(N > 1) { printf("-1/n");continue; } //要考虑因子 2或因子3的搭配了 if (dim[0] % 3 == 0) //因子里都组成了8 { if (dim[1] % 2) putchar('3'); for (int i = 0; i < dim[2]; ++ i) putchar('5'); } else if (dim[1] % 2 == 0) //因子里的3都组成了9 { if (dim[0] % 3 == 1) putchar('2'); else putchar('4'); for (int i = 0; i < dim[2]; ++ i) putchar('5'); } else // 2个2 一个 3 或者1个2,1个3 { for (int i = 0; i < dim[0] % 3 - 1;++i) putchar('2'); for (int i = 0; i < dim[2]; ++ i) putchar('5'); putchar('6'); } for (int i = 0; i < dim[3];++i) putchar('7'); for (int i = 0; i < dim[0] /3;++i) putchar('8'); for (int i = 0; i < dim[1] / 2;++i) putchar('9'); putchar('/n'); } return 0; }