tc=int(raw_input())
while tc>0:
    tc=tc-1
    N,K=map(int,raw_input().split())
    s=''
    for I in xrange(N):
        if (I%2)==0:
            s+='a'
        else:
            s+='b'
    #print s
    s1=s[:]
    count=0
    for i in xrange(1,10):
        s=s.replace(s[0],str(i))
        for j in xrange(0,10):
            if i!=j:
                s=s.replace(s[1],str(j))
                count+=1
            if count==K:
                print s
                break
        if count==K:
            break
        elif count>K:
            print '-1'
        else:
            s=s1[:]
    else:
        print '-1'