|
||||||||||
GameTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 384 Accepted Submission(s): 222 Problem Description BrotherK is very rich. He has a big company. One day, BrotherK wants to give an award to one of the employees in the company. It's so hard to make a choise that BrotherK decides to play a game to determine the lucky dog. At the beginning of the game, all $N$ employees form a circle. Then, they receive t-shirts with numbers 1 through $N$ in clockwise order along the circle. The game consists of many turns. In the ith turn, BrotherK starts by standing in front of a employee and announces a number $X_i$. He will move to the ($X_i+1$)th-next-employee in clockwise order, and the $X_i$th-next-employees will be removed from the circle, then the (i+1)th turn starts. Attention that the 1th-next-employee of a employee is itself, and BrotherK stands in front of the employee with number 1 at first. In the ith turn, The value of $X_i$ is chosen randomly from a given integer set $S$. When there is only one employee left in the game, the game ends and the employee wins the award. You are given the int $N$ and the set of integers, BrotherK wants to know which employees are possible to win. Input The first line contains a single integer $T$, indicating the number of test cases. Each test case begins with two integer $N, M$, indicating the number of employees in BrotherK's company, and the size of BrotherK's integer set $S$. Next line contains $M$ numbers, from $a_1$ to $a_M$, indicating the integer in $S$. $T$ is about 50 $1~\le~N, M~\le~200$ $1~\le~a_i~\le~10^9$ Output For each test, print two lines. The first line contains a integer $K$, indicating how many people are possible to win. The second line contains $K$ number, indicating the number in T-shirt who can win, in ascending order. Sample Input
Sample Output
Source | ||||||||||
|