#include <iostream>
using namespace std;
int t, n, book[] = {-1, -1, 1, 7, 4, 2, 6, 8, 10, 18, 22, 20, 28, 68, 88};
int main()
{
cin >> t;
while(t--)
{
cin >> n;
if(n <= 14) cout << book[n] << endl;
else
{
cout << book[(n - 14) % 7 + 7];
for(int i = 1; i <= (n - 14) / 7 + 1; i++) cout << 8;
cout << endl;
}
}
return 0;
}