Division Avoidance
시간 제한2초메모리 제한2048 MB
분열을 반복해 금지된 격자 칸을 하나도 포함하지 않는 세포 집합을 만들 수 있는지 판정한다.
문제
A newly discovered organism can be represented as a set of cells on an infinite grid. There is a coordinate system on the grid such that each cell has two integer coordinates and . A cell with coordinates and will be denoted as .
Initially, the organism consists of a single cell . Then zero or more divisions can happen. In one division, a cell is removed and replaced by two cells and .
For example, after the first division, the organism always consists of two cells and , and after the second division, it is either the three cells , and , or the three cells , and .
A division of a cell can only happen if the cells and are not yet part of the organism. For example, the cell cannot divide if the organism currently consists of the three cells , and , since the cell that would be one of the results of this division is already part of the organism.
You are given a set of forbidden cells . Is it possible for the organism to contain none of those cells after zero or more divisions?
입력
Each test contains multiple test cases. The first line contains an integer () — the number of test cases. The descriptions of the test cases follow.
The first line of each test case contains an integer () — the number of forbidden cells.
The next lines contain two integers each. The -th of such lines contains and () — the coordinates of the -th forbidden cell. It is guaranteed that all forbidden cells are distinct.
It is guaranteed that the sum of values of over all test cases does not exceed .
출력
For each test case, print YES if it is possible for the organism to contain no forbidden cells after zero or more divisions. Otherwise, print NO.