def find_wobbly(k):
	a = 1
	i = 1
	b = 0
	while i < k:
		i = i + 1
		if b != 9:
			b = b + 1
			if b == a:
				if b == 9:
					if a == 9:
						a = -1
						return a, b
					else:
						a = a + 1
						b = 0
				else:
					b = b + 1
		else:
			b = 0
			if a != 9:
				a = a + 1
			else:
				a = -1
				return a, b
	return a, b
	
	
def make_wobbly(length, k):
	a, b = find_wobbly(k)
	if a == -1:
		return -1
	i = 1
	num = 0
	while i <= length:
		num = num * 10
		if i%2 == 0:
			num = num + b
		else:
			num = num + a
		i = i + 1
	return num
	
def input():
	cases = int(raw_input())
	for case in range(cases):
		length, k = raw_input().split()
		length = int(length)
		k = int(k)
		ans.append(make_wobbly(length, k))
	

ans = []

input()

for answer in ans:
	print answer