五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

CF 1806A. Walking Master

2023-06-08 20:40 作者:您是打尖兒還是住店呢  | 我要投稿

YunQian is standing on an infinite plane with the Cartesian coordinate system on it. In one move, she can move to the diagonally adjacent point on the top right or the adjacent point on the left.That is, if she is standing on point (x,y)

, she can either move to point (x+1,y+1)

?or point (x?1,y)

YunQian initially stands at point (a,b)

?and wants to move to point (c,d)

. Find the minimum number of moves she needs to make or declare that it is impossible.


Input

The first line contains a single integer t (1≤t≤104) — the number of test cases. The description of test cases follows.

The first line and only line of each test case contain four integers a, b, c, d (?108≤a,b,c,d≤108).

Output

For each test case, if it is possible to move from point (a,b) to point (c,d)

, output the minimum number of moves. Otherwise, output ?1

Example

input

6

-1 0 -1 2

0 0 4 5

-2 -1 1 1

-3 2 -3 2

2 -1 -1 -1

1 1 0 2

outputCopy

4

6

-1

0

3

3

Note

In the first test case, one possible way using 4 moves is (?1,0)→(0,1)→(?1,1)→(0,2)→(?1,2)

. It can be proven that it is impossible to move from point (?1,0) to point (?1,2) in less than 4

?moves.

就是判斷移動的次數(shù)跟能不能移動到,,主要是先判斷Y值的大小,因為只能想右上方跟左邊行走,所以判斷y值的大小變化,再根據(jù)y值大小變化去比較x值的大小,即可返回;下面是代碼:


CF 1806A. Walking Master的評論 (共 條)

分享到微博請遵守國家法律
三门县| 兴义市| 深州市| 安塞县| 河北省| 茌平县| 高碑店市| 汶上县| 安丘市| 班玛县| 分宜县| 芦溪县| 五华县| 长汀县| 云梦县| 新源县| 三亚市| 黎城县| 濮阳县| 碌曲县| 阿尔山市| 呼图壁县| 资兴市| 甘洛县| 潍坊市| 海阳市| 密山市| 聂荣县| 阜平县| 从化市| 绥滨县| 平昌县| 花垣县| 乌鲁木齐市| 盐城市| 丽江市| 揭阳市| 望城县| 沁阳市| 蓝山县| 昌都县|