fork(2) download
  1. n = input()
  2. for i in xrange(n):
  3. x, y = map(int, raw_input().split(' '))
  4. z = x - y
  5. if(z % 2 == 0 and z >= 0):
  6. p = z / 2
  7. q = y
  8. a = 0
  9. b = 0
  10. f = True
  11. for i in xrange(64):
  12. if((p & (1 << i)) and not (q & (1 << i))):
  13. a |= (1 << i);
  14. b |= (1 << i)
  15. elif(not (p & (1 << i)) and (q & (1 << i))):
  16. b |= (1 << i)
  17. elif(not (p & (1 << i)) and (not q & (1 << i))):
  18. pass
  19. else:
  20. print -1
  21. f = False
  22. break
  23. if(f):
  24. print a, b
  25. assert(a + b == x and a ^ b == y)
  26. else:
  27. print -1
Success #stdin #stdout 0.01s 23352KB
stdin
5
4 2
3 4
3 3
5 2
9 5
stdout
1 3
-1
0 3
-1
2 7