N = int(input())
for i in range(N):
A,B = [int(i) for i in input().split()]
if A == 33 and B <= 30:
AA = [11,11,11]
if B == 30:
BB = [10,10,10]
else:
BB = [10]*(B//10) + [B%10]
BB += [0]*(3-len(BB))
elif 33 < A <= 44 and B <= 41:
if A == 44:
AA = [11,11,11,11]
else:
AA = [A%11,11,11,11]
if B == 41:
BB = [11,10,10,10]
else:
BB = [11] + [10]*((B-11)//10) + [(B-11)%10]
BB += [0]*(4-len(BB))
elif 44 < A <= 53 and B <= 52:
if A == 53:
AA = [10,10,11,11,11]
else:
AA = [(A-33)%10] + [10]*(B-33)//10 + [11,11,11]
if B == 52:
BB = [11,11,10,10,10]
else:
BB = [11,11] + [10]*((B-22)//10) + [(B-22)%10]
BB += [0]*(5-len(BB))
else:
AA = [-1]
BB = [-1]
## print(AA)
## print(BB)
for i in range(len(AA)):
print(AA[i],BB[i])