n = input()
for i in xrange(n):
x, y = map(int, raw_input().split(' '))
z = x - y
if(z % 2 == 0 and z >= 0):
p = z / 2
q = y
a = 0
b = 0
f = True
for i in xrange(64):
if((p & (1 << i)) and not (q & (1 << i))):
a |= (1 << i);
b |= (1 << i)
elif(not (p & (1 << i)) and (q & (1 << i))):
b |= (1 << i)
elif(not (p & (1 << i)) and (not q & (1 << i))):
pass
else:
print -1
f = False
break
if(f):
print a, b
assert(a + b == x and a ^ b == y)
else:
print -1
biA9IGlucHV0KCkKZm9yIGkgaW4geHJhbmdlKG4pOgoJeCwgeSA9IG1hcChpbnQsIHJhd19pbnB1dCgpLnNwbGl0KCcgJykpCgl6ID0geCAtIHkKCWlmKHogJSAyID09IDAgYW5kIHogPj0gMCk6CgkJcCA9IHogLyAyCgkJcSA9IHkKCQlhID0gMAoJCWIgPSAwCgkJZiA9IFRydWUKCQlmb3IgaSBpbiB4cmFuZ2UoNjQpOgoJCQlpZigocCAmICgxIDw8IGkpKSBhbmQgbm90IChxICYgKDEgPDwgaSkpKToKCQkJCWEgfD0gKDEgPDwgaSk7CgkJCQliIHw9ICgxIDw8IGkpCgkJCWVsaWYobm90IChwICYgKDEgPDwgaSkpIGFuZCAocSAmICgxIDw8IGkpKSk6CgkJCQliIHw9ICgxIDw8IGkpCgkJCWVsaWYobm90IChwICYgKDEgPDwgaSkpIGFuZCAobm90IHEgJiAoMSA8PCBpKSkpOgoJCQkJcGFzcwoJCQllbHNlOgoJCQkJcHJpbnQgLTEKCQkJCWYgPSBGYWxzZQoJCQkJYnJlYWsKCQlpZihmKToKCQkJcHJpbnQgYSwgYgoJCQlhc3NlcnQoYSArIGIgPT0geCBhbmQgYSBeIGIgPT0geSkKCWVsc2U6CgkJcHJpbnQgLTE=