#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
for(int i=0;i<t;i++){
int n;
cin>>n;
int temp=n%7;
if(n==0){
cout<<-1;
}else if(temp==0){
for(int j=0;j<n/7;j++){
cout<<8;
}
}else if(n==1){
cout<<-1;
}else if(temp==1){
cout<<10;
for(int j=0;j<(n-8)/7;j++){
cout<<8;
}
}else if(temp==2){
cout<<1;
for(int j=0;j<(n-2)/7;j++){
cout<<8;
}
}else if(temp==3){
if(n==3)cout<<7;
else if(n==17)cout<<200;
else if(n==10){
cout<<22;
}else if(n==24){
cout<<2288;
}else{
cout<<7;
for(int j=0;j<(n-17)/7;j++){
cout<<8;
}
}
}else if(temp==4){
if(n==11){
cout<<20;
continue;
}else if(n==18){
cout<<208;
continue;
}
cout<<4;
for(int j=0;j<(n-11)/7;j++){
cout<<8;
}
}else if(temp==5){
cout<<2;
for(int j=0;j<(n-5)/7;j++){
cout<<8;
}
}else if(temp==6){
cout<<6;
for(int j=0;j<(n-6)/7;j++){
cout<<8;
}
}else if(n==17){
cout<<200;
}
cout<<endl;
}
return 0;
}