Grid Game

시간 제한2초메모리 제한512 MB

요약
흰 칩은 위나 오른쪽으로, 검은 칩들은 아래나 왼쪽으로 이동하며, 흰 칩이 검은 칩과 같은 칸에 오지 않고 10^100번의 이동을 버틸 수 있는지 판정한다.
난이도

보통10점 중 6점

유형
그리디, 게임 이론, 수학
정답자
아직 제출이 없습니다

문제

Consider an infinite two-dimensional grid. A white chip is placed in the cell (0, 0). There are also n black chips, the i-th of which is initially in the cell (xi, yi). Some chips may occupy the same cells.

Two player play a game, taking turns starting with the first player. On his turn, the first player must move the white chip from its current cell (x, y) to (x + 1, y) or (x, y + 1). The second player must move each black chip from its current position (x, y) to (x − 1, y) or (x, y − 1), choosing directions for each chip independently. If at any moment (after first or second player’s turn) the white chip shares its cell with any black chip, the first player immediately loses the game. If the first player manages to make 10100 turns without losing, he wins. Determine if the first player can win regardless of the strategy of the second player.

입력

The first line contains an integer t: the number of test cases.

Each test case starts with a line with a positive integer n denoting the number of black chips. It is followed by n lines, each containing two integers xi and yi (0 ≤ xi, yi ≤ 100, xi + yi > 0).

It is guaranteed that the total amount of black chips over all test cases does not exceed 104.

출력

For each test case, print a separate line with a single word: “Yes” if the first player can win, or “No” otherwise.

예제1

  1. 예제 1

    입력
    3
    1
    3 3
    2
    2 0
    1 2
    4
    2 0
    2 3
    1 6
    5 2
    
    예상 출력
    No
    Yes
    Yes