import math

testcases = input()
#print "Testcases: %d" %testcases

lengthArray = [1]*testcases

kthArray = [1]*testcases

for i in range(0,testcases):
    case = raw_input()
    numbers = case.split(' ')
    #print numbers

    lengthArray[i] = int(numbers[0])
    #print lengthArray
    kthArray[i] = int(numbers[1])
    #print kthArray

#print lengthArray
#print kthArray
a = 0
b = 0


for i in range(0,testcases):
    a = int(math.ceil(kthArray[i]/9.0))

    if a > 9:
        print -1
        continue

    tmp = kthArray[i]%9

    if tmp <= a:
        b = tmp-1
        if b < 0:
            if a == 9:
                b = 8
            else:
                b = 9
    else:
        b = tmp
    stringToPrint = ""
    for j in range(0,lengthArray[i]):
        if j%2 == 0:
            stringToPrint = stringToPrint + str(a)
        else:
            stringToPrint = stringToPrint + str(b)
    print stringToPrint