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

分享到微博請遵守國家法律
凉城县| 铜鼓县| 普陀区| 永德县| 临武县| 阳东县| 砚山县| 安泽县| 桦甸市| 临海市| 高青县| 万载县| 班戈县| 永安市| 依安县| 油尖旺区| 获嘉县| 西和县| 达拉特旗| 通化县| 民权县| 新巴尔虎右旗| 永城市| 田林县| 新宁县| 东乡县| 宁城县| 清涧县| 武冈市| 镇赉县| 武川县| 枣强县| 甘德县| 蓝山县| 萍乡市| 武城县| 安岳县| 松阳县| 建昌县| 永昌县| 三明市|