五月天青色头像情侣网名,国产亚洲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的評論 (共 條)

分享到微博請遵守國家法律
西昌市| 大宁县| 石河子市| 临武县| 瑞昌市| 库伦旗| 正宁县| 吕梁市| 阜阳市| 湖南省| 清流县| 上思县| 易门县| 延安市| 通州区| 高平市| 牙克石市| 乌拉特中旗| 永城市| 老河口市| 漠河县| 凤城市| 张北县| 鄂托克旗| 咸阳市| 镇巴县| 资阳市| 团风县| 山东省| 海门市| 葵青区| 夹江县| 涟源市| 林口县| 碌曲县| 乡城县| 驻马店市| 金坛市| 浪卡子县| 桂林市| 盖州市|