Time Limit: 3000/1500 MS (Java/Others)

Memory Limit: 262144/262144 K (Java/Others)

MG is a rich boy. He has $n$ apples, each has a value of V($0<=V<=9$).

A valid number does not contain a leading zero, and these apples have just made a valid $N$ digit number.

MG has the right to take away $K$ apples in the sequence, he wonders if there exists a solution: After exactly taking away $K$ apples, the valid $N-K$ digit number of remaining apples mod $3$ is zero.

MG thought it very easy and he had himself disdained to take the job. As a bystander, could you please help settle the problem and calculate the answer?

A valid number does not contain a leading zero, and these apples have just made a valid $N$ digit number.

MG has the right to take away $K$ apples in the sequence, he wonders if there exists a solution: After exactly taking away $K$ apples, the valid $N-K$ digit number of remaining apples mod $3$ is zero.

MG thought it very easy and he had himself disdained to take the job. As a bystander, could you please help settle the problem and calculate the answer?

The first line is an integer $T$ which indicates the case number.（$1<=T<=60$)

And as for each case, there are $2$ integer $N(1<=N<=100000)$,$K(0<=K$$<$$N)$ in the first line which indicate apple-number, and the number of apple you should take away.

MG also promises the sum of $N$ will not exceed $1000000$。

Then there are $N$ integers $X$ in the next line, the i-th integer means the i-th gold’s value($0<=X<=9$).

And as for each case, there are $2$ integer $N(1<=N<=100000)$,$K(0<=K$$<$$N)$ in the first line which indicate apple-number, and the number of apple you should take away.

MG also promises the sum of $N$ will not exceed $1000000$。

Then there are $N$ integers $X$ in the next line, the i-th integer means the i-th gold’s value($0<=X<=9$).

提交代码