for _ in xrange(int(raw_input())):
    NK=raw_input().split()
    N=int(NK[0])
    K=int(NK[1])
    i=0
    def WobblyYielder(N):
        for aInt in xrange(1,10):
            Blist=[ str(b) for b in xrange(0,10) if b!=aInt]
            a=str(aInt)
            for b in Blist:
                WobblyNumber=''
                x=0
                Flag=True
                while x<N:
                    x+=1
                    if Flag:
                        WobblyNumber+=a
                        Flag=False
                    else:
                        WobblyNumber+=b
                        Flag=True
                yield int(WobblyNumber)
    for num in WobblyYielder(N):
        i+=1
        if i==K:
            print num
            break
    if i<K:
        print -1