#P2575. 高手过招

高手过招

Description

AKN got tired of playing video games, so he started a game of checkers with his teammate. The opponent is wwx. When these two ancient masters meet over the board, the game becomes unpredictable. When masters clash, there will be a winner. They both play optimally. You are given an n×20n \times 20 board with some pieces on it. Who wins? AKN moves first.

The rules of the game are as follows:

  • For any piece, you may move it one cell to the right. If there is a piece immediately to its right, then jump to the first empty cell to the right. If there is no empty cell to the right, you cannot move this piece. If none of the pieces can move, you lose the game.

Input Format

The first line contains TT, the number of test cases.

For each test case, the first line contains nn, indicating an n×20n \times 20 board.

Then follow nn lines; on each line, the first number mm indicates that row ii has mm pieces.

It is then followed by mm numbers pjp_j describing the piece positions in row ii.

Output Format

If AKN can win, print YES; otherwise, print NO.

2
1
2 19 20
2
1 19
1 18

NO
YES

Hint

10%10\% of the testdata has T1,n1T \leq 1, n \leq 1.

Additionally, 10%10\% of the testdata has m1m \leq 1.

For 100%100\% of the testdata, T100T \leq 100, n1000n \leq 1000, m20m \leq 20, 1pj201 \leq p_j \leq 20.

Translated by ChatGPT 5