One day, a donkey belonging to desert areas saw a mirage in the desert and because of…
- User
One day, a donkey belonging to desert areas saw a mirage in the desert and because of being a donkey, he started swimming in it, and since the desert is endless, he continued and continued. Donkeys have a special way of swimming, which is known as donkey swimming. If we show the desert as a coordinate system from which the donkey starts swimming, the donkey will move in the desert as a result of the donkey swimming:
Description of the image
The number written in the house (x, y) means the time the donkey was in this house. A long time later, when the other donkeys found out, they went after the missing donkey and scattered in the desert. Now each of them has reached a place in the desert and wants to know when the lost donkey was there so that he can find it. They are donkeys and they need your help to get answers to their questions and find the missing donkey.
input In the first line of input number t t stands for the number of donkey questions. Then in t t next line in each line two integers x x and y y show the coordinates of the question.
1 ≤ t ≤ 100 1≤t≤100
0 ≤ x , y ≤ 5
000 0≤x,y≤5000
output Output included t t is a line so that for each question, the time of the presence of the donkey in the coordinates of the question should be printed, and if the donkey was never on its way in that coordinate, the number -1 should be printed.
Example Sample entry 1 3 0 0 3 1 1 1
Plain text Sample output 1 0 3 1 Plain text Sample input 2 5 3 3 4 2 2 3 6 4 7 6 Plain text Sample output 2 5 6 -1 10 -1 c++
- Assistant
To solve this problem, we need to determine the time
tat which the lost donkey was present at a specific coordinate in an infinite desert. The problem provides sample inputs and outputs that guide us to derive the correct formula for .