P28565 [洛谷] [SDOI2010] Alien Centipedes
提高
题目描述

Problem Description

In February 3rd, 2333, after a journey of 17 years and 3 months, the manned return capsule of the "Ganagulu No.1" rocket finally landed safely. This rocket, developed and launched by NASA, traveled through 23 solar system planets including Mars, Venus, Titan, Europa, Ceres, and "Zhangheng Star," and eventually discovered extraterrestrial life on the asteroid "Jason Star." Astronauts found a batch of precious living samples at a depth of 45.70 meters below the surface of "Jason Star" and brought them back for testing.

Among the returned living samples, the most fascinating were the alien centipedes. These creatures have slender bodies divided into several segments. When touched, they curl their bodies into a circular shape and only resume movement after a period of time.

What's even more interesting is that these centipedes do not have paired legs like Earth's centipedes, totaling an even number. Each segment of their body has an indeterminate number of legs, but the total number of legs is always odd!

Although it is difficult to distinguish them by appearance, scientists can determine the origin of the centipedes by counting the number of legs and checking their parity.

As a secret spy from Country J sent to NASA, you hope to participate in this research activity to obtain further intelligence, and NASA selects only the most outstanding scientists. Therefore, NASA Director Charles Bolden has devised a difficult problem to test your abilities:

You are presented with N centipedes numbered from 1 to N, and your task is to identify the origin of each centipede without counting their legs.

Charles will select several centipedes from these N and place them in the "Insect Feet Counter" (IFC), which automatically counts the total number of legs. Charles will then provide you with the result of this sum modulo 2, along with the identification of the centipedes initially placed in the machine.

He will perform this statistical operation a total of M times, and you should determine the results as early as possible.

If by the K-th statistical operation, the data is sufficient to identify each centipede, you should also report this K to Charles. If K < M, it indicates that the subsequent M - K operations were not necessary.

If, based on all M statistical operations, it is still impossible to determine the identity of each centipede, you must inform Charles that there are multiple solutions based on the current data.

Input Format

The first line contains two positive integers N and M.

The next M lines sequentially provide the results of Charles's M uses of the "Insect Feet Counter." Each line contains a 01 string and a number, separated by a space. The 01 string indicates whether each centipede was placed in the machine: '0' means the centipede was not placed, and '1' means it was placed. The number following is the result of the total number of legs modulo 2.

Given that NASA's experimental machines are accurate and consistent, the data provided will not contradict itself, ensuring that there is always a solution.

Output Format

If there is a unique solution, output N+1 lines. The first line should contain a positive integer K, no more than M, indicating that a unique solution can be determined after the K-th statistical operation. The next N lines should sequentially identify each centipede: output ?y7M# if the number of legs is odd, and Earth if even.

If there are multiple solutions, output Cannot Determine.

Sample Input and Output

Input Sample #1

3 5
011 1
110 1
101 0
111 1
010 1

Output Sample #1

4
Earth
?y7M#
Earth

Input Sample #2

5 7
01100 1
11000 1
10100 0
11100 1
00011 1
00000 0
11111 0

Output Sample #2

Cannot Determine

Notes/Hints

Scoring Criteria

For each test case, if your output file matches the answer file exactly, you will receive full marks.

Otherwise, for test cases with a unique solution, if you correctly identify all centipedes, you will receive 50% of the points.

In other cases, you will receive zero points.

Data Size and Constraints

For 20% of the data, N = M ≤ 20;

For 40% of the data, N = M ≤ 500;

For 70% of the data, N ≤ 500, M ≤ 10^3;

For 100% of the data, 1 ≤ N ≤ 10^3, 1 ≤ M ≤ 2 × 10^3.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 5 011 1 110 1 101 0 111 1 010 1
样例输出
4 Earth ?y7M# Earth