Universal Cup Judging System

Universal Cup

시간 제한: 2.0 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓
통계

There are $N$ points on a number line. Initially, the $i$-th point is at coordinate $A_i$.

You can perform the following operations any number of times, in any order:

  • Choose two distinct points $i$ and $j$, and swap them.
  • Choose two distinct points $i$ and $j$, and mirror point $i$ across point $j$. Formally, set $A_i := 2A_j - A_i$.

Is it possible to have the $i$-th point be at $B_i$ after all operations for all $1 \le i \le N$?

Input

The input is given in the following format:

T
N
A_1 B_1
A_2 B_2
:
A_N B_N
:
  • All input values are integers.
  • $1 \le T \le 10^4$
  • $1 \le N \le 2 \times 10^5$
  • $-10^9 \le A_i, B_i \le 10^9$
  • It is guaranteed that the sum of $N$ over all test cases does not exceed $2 \times 10^5$.

Output

For each test case, output YES if it is possible to reach the desired final configuration, and NO otherwise.

You can output the answer in any case. For example, the strings YES, yes, and yEs will all be recognized as positive responses.

Examples

Sample Input 1

6
1
1 1
1
0 2
2
0 3
1 2
2
1 5
2 7
3
-3 5
9 13
7 5
3
-3 11
9 25
7 9

Sample Output 1

YES
NO
YES
NO
NO
YES

Note

Test case 3: One valid sequence of operations is:

  1. Start from coordinates $[0, 1]$.
  2. Mirror point $1$ across point $2$. The coordinates become $[2, 1]$.
  3. Swap point $1$ with point $2$. The coordinates become $[1, 2]$.
  4. Mirror point $1$ across point $2$. The coordinates become $[3, 2]$.

Test cases 2, 4, and 5: It can be proven that it is impossible to have the points at the desired coordinates.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.