def getNDigitWobble(a,b,n):
	num=a
	i=1
	while(i<n):
		if(i%2==1):
			num=num*10+b
		else:
			num=num*10+a
		i=i+1
	return num
	

t=input()
while(t>0):
	n,k=(int(x) for x in raw_input().split())
	li=list()
	for a in range(9):
		for b in range(10):
			if(a+1!=b):
				li.append(getNDigitWobble(a+1,b,n))
	li.sort()
	if(k<=len(li)):
		print li[k-1]
	else:
		print -1
	t=t-1