**1 人解决**，2 人已尝试。

**1 份提交通过**，共有 4 份提交。

**9.8** EMB 奖励。

**单点时限: **2.0 sec

**内存限制: **256 MB

You are trying to compute the next number in a sequence Sn generated by a secret code. You know that the code was generated according to the following procedure.

First, for each k between 0 and 29, choose a number Ck between 0 and 10006 (inclusive).

Then, for each integer n between 0 and 1 000 000 000 (inclusive):

- Write n in binary.
- Take the numbers Ck for every bit k that is set in the binary representation of n. For example, when n=5, bits 0 and 2 are set, so C0 and C2 are taken.
- Add these Ck together, divide by 10007, and output the remainder as Sn.

You will be given a series of consecutive values of sequence S, but you don’t know at which point in the sequence your numbers begin (although you do know that there is at least one more number in the sequence), and you don’t know what values of Ck were chosen when the sequence was generated.

Find the next number in the sequence, or output UNKNOWN if this cannot be determined from the input data.

The first line will contain an integer T(1 ≤ T ≤ 20), the number of test cases in the input file.

For each test case, there will be:

- One line containing the integer N(1 ≤ N ≤ 1000), the number of elements of sequence S that you have.
- One line containing N single-space-separated integers between 0 and 10006, the known elements of the sequence.

For each test case, output one line containing “Case #X: Y” where X is the number of the test case, starting from 1, and Y is the next number in the sequence, or the string UNKNOWN if the next number cannot be determined.

Input

3 7 1 2 3 4 5 6 7 4 1 10 11 200 4 1000 1520 7520 7521

Output

Case #1: UNKNOWN Case #2: 201 Case #3: 3514 Hint: In the first case, C0, C1 and C2 might have been 1, 2 and 4, and the values of Sn we have starting at n=1. If this is correct, we don't know C3, so the next number in the sequence could be anything! Therefore the answer is unknown. In the second case, we cannot know all the values of Ck or even what n is, but we can prove that in any sequence, if 1, 10, 11, 200 occur in order, then the next value will always be 201.

**1 人解决**，2 人已尝试。

**1 份提交通过**，共有 4 份提交。

**9.8** EMB 奖励。

题目标签