This problem has no relation with Problem H Morrow by Morrow.
TSUCE (Time-Space Union of Coding Experts) is preparing to host the TSUCE Programming Duel Cup, an algorithmic programming 1v1 duel between two players!
The competition format is as follows. Please note the meanings of $$$n$$$ and $$$m$$$:
Unfortunately, the scorekeeper Little T's database broke down. He only remembers the scores of all $$$k$$$ matches, but he forgot $$$n$$$ and $$$m$$$ related to the format.
Please help him determine whether there exists a valid pair of positive integers $$$n$$$ and $$$m$$$ such that all these scores are valid under this format.
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^5$$$), representing the number of test cases.
The first line of each test case contains an integer $$$k$$$ ($$$1 \le k \le 10^5$$$), representing the number of recorded matches.
Each of the following $$$k$$$ lines contains two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{18}, |a - b| \ge 2$$$), representing the score of a match recorded in Little T's database.
It is guaranteed that $$$\sum k \le 3 \times 10^5$$$ over all test cases.
For each test case, if there exists a valid pair of positive integers $$$n$$$ and $$$m$$$ such that all these scores are valid under this format, output a string YES on a single line; otherwise, output a string NO on a single line.
Note that the evaluation is case-insensitive for YES and NO. In other words, when the answer is positive, outputs like yes, YES, Yes, YeS will all be considered correct.
6316 1410 1619 22211 1619 2252 1316 129 1313 1020 2225 75 930 55 211 726 99 6
YES YES YES NO YES YES
For the 3rd test case, we can find that $$$n = 12$$$, $$$m = 3$$$ is a valid solution. The matches will go through the following processes: