P14776 [CodeChef] CHANGEPOS
普及-
题目描述

There is $a 10 \times 10$ grid with rows numbered 1 to 10 from top to bottom, and columns 1 to 10 from left to right. Each cell is identified by a pair (r, c) which means that the cell is located at row r and column c.

If Chef's current location is (a,b), then in one move Chef can go to (c,d) if both of the following are satisfied:
$a \neq c$
$b \neq d$

Determine the minimum number of moves required to go from (s_{x}, s_{y}) to (e_{x}, e_{y}).

------ Input Format ------

  • The first line contains a single integer T — the number of test cases. Then the test cases follow.
  • The first and only line of each test case contains four integer s_{x}, s_{y}, e_{x}, e_{y} — the coordinates of the starting and ending cells.

------ Output Format ------

For each testcase, output the minimum number of moves required to go from (s_{x}, s_{y}) to (e_{x}, e_{y}).

------ Constraints ------

$1 ≤ T ≤ 1000$
$1 ≤ s_{x}, s_{y}, e_{x}, e_{y} ≤ 10$
$(s_{x},s_{y}) \neq (e_{x},e_{y})$

----- Sample Input 1 ------
4
1 2 9 8
5 5 5 7
8 6 6 8
3 10 8 10

----- Sample Output 1 ------
1
2
1
2

----- explanation 1 ------
Test case 1: Chef can go from $(1, 2)$ to $(9, 8)$ in one move since $1 \neq 9$ and $2 \neq 8$.

Test case 2: Chef will require at least two moves. One such sequence of moves is $(5, 5) \rightarrow (2, 3) \rightarrow (5, 7)$.

输入格式

见题面

输出格式

见题面

样例输入
4 1 2 9 8 5 5 5 7 8 6 6 8 3 10 8 10
样例输出
1 2 1 2