P15709 [CodeChef] TWOROOKS
普及-
题目描述

You are given $a standard 8 \times 8 chessboard which has exactly 2$ rooks on it and no other pieces. The rows are numbered 1 to 8 from bottom to top, and the columns are numbered 1 to 8 from left to right. The cell at the intersection of the i-th column and j-th row is denoted (i,j).

Given the initial positions of the rooks in the form of coordinates (X_{1},Y_{1}) and (X_{2},Y_{2}), you need to tell whether the 2 rooks currently attack each other or not. Assume, each square can contain at most one piece.

Rooks can only travel in straight lines along the row or column they are placed at, and can't jump over other pieces. For a more detailed explanation of the moves of rooks, along with images, please [click here]#Placement_{and}_movement).

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

  • The first line contains T - the number of test cases. Then the test cases follow.
  • The first line of each test case contain four space-separated integers each X_{1}, Y_{1}, X_{2}, Y_{2} - (X_{1},Y_{1}) is the position of the first rook and (X_{2},Y_{2}) is the position of the second rook.

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

For each test case, output on a single line YES (without quotes) if the rooks attack each other, and NO otherwise.

You may print each character of the string in uppercase or lowercase (for example, the strings YeS, YEs, yes and yeS will all be treated as identical).

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

$1 ≤ T ≤ 5000$
$1 ≤ X_{1}, X_{2}, Y_{1}, Y_{2} ≤ 8$
$(X_{1},Y_{1}) \neq (X_{2},Y_{2})$

----- Sample Input 1 ------
3
1 2 5 2
1 2 1 5
1 1 8 8

----- Sample Output 1 ------
YES
YES
NO

----- explanation 1 ------
- Test case $1$: The two rooks can attack each other by moving along the second column.
- Test case $2$: The two rooks can attack each other by moving along the first row.
- Test case $3$: No matter how a rook moves it cannot reach the second rook in one move. Hence, they do not attack each other.

输入格式

见题面

输出格式

见题面

样例输入
3 1 2 5 2 1 2 1 5 1 1 8 8
样例输出
YES YES NO