Every Queen
시간 제한2초메모리 제한1024 MB
각 퀸이 같은 행, 같은 열, 또는 같은 대각선 위의 칸을 공격할 때, 모든 퀸이 공격하는 칸을 하나 찾는다.
문제
There are chess queens on an infinite grid. They are placed in squares with coordinates . Your task is to find a square that all queens attack, or report that no such square exists.
A queen in square attacks square if at least one of the following conditions is satisfied:
- ;
- ;
- .
Note that in this problem, the queens do not block each other. For example, if there are queens in squares and , both of them attack square . Moreover, you can choose a square that already contains a queen. For example, square would be a valid answer in this case.
입력
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer , denoting the number of queens ().
The -th of the following lines contains two integers and , denoting the coordinates of the square containing the -th queen (). No two queens share the same square.
It is guaranteed that the sum of over all test cases does not exceed .
출력
For each test case, if an answer exists, print "YES" in the first line. Then, in the second line, print two integers and , denoting the coordinates of a square attacked by every queen ().
If no such square exists, print a single line containing "NO" instead.
It can be shown that if an answer exists, there also exists an answer that satisfies . If there are multiple answers, print any of them.