# author s2c2

def getWobbly(a,b,c) :
	#print "-----",a,b,c
	if(a == 0) :
		return "";
	elif(a%2 == 1 ) :
		return str(b) + getWobbly(a-1,c,b);
	else :
		return str(b) + str(c) + getWobbly(a-2,b,c);

def printWobbly(a,b) :
	k=b
	if(k>81) :
		print -1;
	else :
		if(k % 9 == 0 ) :
			c = k/9
			d = 9
			if(c == d) :
				d = 8
		else :
			c = k/9 + 1;
			d = k%9 - 1;
			if(c <= d) :
				d = d+1;
		print getWobbly(a,c,d)

a = input()
for j in xrange(a) :
	c = [int(i) for i in raw_input().strip().split()]
	printWobbly(c[0],c[1])