It is said in the test book that in general, when one body does negative work on a second body, the second body does an equal amount of positive work on the first body.
However, when consider two magnets repelling each other and there is also a normal force acted on one of magnets by a wall...