'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
n=int(raw_input())
def get2ndNo(n1,index):
	if index < n1:
		return index
	else:
		return index+1
for i in range(n):
	a,b = map(int,raw_input().split())
	if b>81:
		print -1
		continue
	b-=1
	num1=(b//9) + 1
	num2=b%9
	num2 = get2ndNo(num1,num2)
	#re-use b as a temp output as now it will not be used
	b=(str(num1)+str(num2))*(a//2)
	if a%2 == 1:
		b+=str(num1)
	print b