def logic(n,k):
    str_1 = ''
    new_str = ''
    wob_list = list()
    for x in range (1,10):
        for y in range (10):
            if (x == y):
                continue
            str_1 = str(x) + str(y)
            str_1 = str_1 * n
            new_str= str_1[:n]
            wob_list.append(new_str)
            if (len(wob_list) >= k):
                break
        if (len(wob_list) >= k):
                break
    try:
        result_set = wob_list[k-1]
        return result_set
    except:
        result_set = -1
        return result_set

t = int(raw_input())
for i in range(1, t+1):
    s = raw_input()
    l = s.split()
    n = int(l[0])
    k = int(l[1])
    r = logic(n,k)
    print r