# UUID: 6ebd04e7-e6ff-49c4-a21e-2c1dde60b697
merkozesek = int(input())
eredmenyek = []
for i in range(merkozesek):
eredmenyek.append(list(map(int, input().strip().split())))
def harombol(b):
if b<11:
return [b, 0, 0]
elif b-10<11:
return [10, b-10, 0]
else:
return [10, 10, b-20]
def tobbol(a, b):
jatszmak = int(a/11)+1
apoints = []
bpoints = []
if jatszmak == 4 and b<52:
apoints.append(a%11)
bpoints.append(11)
if a-a%11 == 33:
bpoints = bpoints + harombol(b-11)
apoints += [11,11,11]
return (apoints, bpoints)
else:
apoints.append(5 if a % 11 == 0 else a % 11)
bpoints.append(11)
apoints.append(6 if a % 11 == 0 else 0)
bpoints.append(11)
if a-a%11 == 33 or a%11 == 0:
bpoints = bpoints + harombol(b-22)
apoints += [11,11,11]
return (apoints, bpoints)
for i in eredmenyek:
if i[0]<33 or i[0] == i[1] or (i[0]==33 and i[1]>=33):
print(-1, -1)
elif i[0] == 33:
bs = harombol(i[1])
for i in range(3):
print(11, bs[i])
else:
a, b = tobbol(i[0],i[1])
for i in range(len(a)):
print(a[i], b[i])