T = int(input())
l = [None]*2
for r in range(0,T):
	s = raw_input()
	l = s.split()
	N = int(l[0])
	K = int(l[1])
	p = 0
	i = 1
	j = 0
	while i<10 and p<K:
		j = 0
		while j<10 and p<K:
			if j==i:
				j = j+1
				if j<10 and p<K:
					p = p+1
			else:
				p = p+1
			j = j+1
		i = i+1
	if p<K:
		print(-1)
	else:
		i = i-1
		j = j-1
		st = ""
		p = i
		for l in range(0, N):
			st = st + str(p)
			if p==i:
				p=j
			else:
				p=i
		print(st)