Problem: In vardhaman college of engineering, there is competition with name treasure lock.
To make this competition the key for the lock should satisfy following rules.
1 .3, 5, or both as its digits. No other digit is allowed.
2. Number of times 3 appears is divisible by 5.
3. Number of times 5 appears is divisible by 3.

Rakesh is very eager to win the championship. He is developing a code for that key.Assume yourself in that situation and solve for the key.

INPUT:
first line contains T testcases.
Next T lines consists of the number.
OUTPUT:
Output the number satisfying the above conditions.
if n cannot satisfy the above conditions print -1.

0<t<10
0<n<1000

SAMPLE INPUT
4
1
3
5
17

SAMPLE OUTPUT
-1
555
33333
55555555555533333

Solution (in PYTHON):

Solution:
m3,m5=[0],[0]
for i in xrange(400):
    m3.append(i*3)
    m5.append(i*5)

def ans(n):
 
    if(n == 0):
       return True
    elif(n < 0):
       return False
    else:
        return ans(n-5) or ans(n-3)
    

for _ in xrange(input()):
    x=input()
    
    if(ans(x)):
        for i in m3:
            if(i<=x):
                for j in m5:
                    if(i+j==x):
                        n=i
                        m=j
                        break
            else:
                break
        if(x%5):
            print str(5)*n+str(3)*m
        else:
            print str(3)*x
    else:
        print -1