QOJ.ac

QOJ

実行時間制限: 1.5 s メモリ制限: 32 MB 満点: 100

#15146. T3 / Array Game

統計

There is an array of length $N$. Two players, A and B, play a game on this array. Initially, some cells are white and some are black. The two players take turns making moves. In each move, a player chooses a white cell at index $x$. Then, they choose an integer $k$ such that $1 \le k \le N/x$, and flip the colors of the cells at indices $x, 2x, \dots, kx$. The player who cannot make a move loses.

Player A (the first player) has several queries. For each query, you are given the initial state of the array, and you must determine if the first player has a winning strategy.

Input

The first line contains an integer $N$, representing the length of the array. The second line contains an integer $K$, representing the number of queries. The next $2 \times K$ lines describe the queries. Each query consists of two lines: the first line contains a positive integer $W$, representing the number of white cells in the array, and the second line contains $W$ positive integers between $1$ and $N$, representing the indices of the white cells.

Output

For each query, output "Yes" if the first player has a winning strategy, otherwise output "No". Separate the answers with newlines.

Examples

Input 1

3
2
2
1 2
2
2 3

Output 1

Yes
No

Note

In the first query, player A chooses index $1$, then flips the cells at $1 \times 1$ and $2 \times 1$. In the second query, no matter which cell player A chooses, they can only flip one cell. Player B only needs to flip the other cell to win.

Constraints

For $30\%$ of the data, $N \le 20$. For $50\%$ of the data, $N \le 1\,000\,000$. For $70\%$ of the data, $N \le 10\,000\,000$. For $100\%$ of the data, $N \le 1\,000\,000\,000$, $K, W \le 100$, and no cell will appear multiple times in the same query.

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.