시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB111100.000%

문제

Danila the Magician and Mia the Assistant are showing a trick with a board.

First, Danila secludes himself, while Mia asks the audience to fill the $8 \times 8$ square table drawn on the board: each cell can contain either zero or one.

Next, another member of the audience chooses the secret number: an integer from $1$ to $64$. The number is announced to Mia but not to Danila.

After that, Mia comes to the board and changes exactly one number on it: either a zero into one, or a one into zero.

Finally, Danila returns, looks at the board for a while, and happily announces the secret number he did not know.

How do they perform the trick? Help Danila and Mia to prepare and then show it.

인터랙션 프로토콜

In this problem, your solution will be run twice on each test. Each test can contain several test cases.

During the first run, the solution acts as Mia the Assistant: given a board and a secret number, it has to change exactly one number on the board. The first line contains the word "Mia". The second line contains an integer $t$: the number of test cases ($1 \le t \le 1000$). The test cases follow. Each consists of nine lines. The first eight lines contain eight space-separated integers each: the numbers on the board (each equal to either $0$ or $1$). The ninth line contains the secret number (an integer from $1$ to $64$).

To answer a test case, the solution must print nine lines. On each of the first eight lines, print eight space-separated numbers: the numbers on the board (each equal to either $0$ or $1$). When comparing to the input, exactly one of them must be different: either a zero must turn into one or a one must turn into zero. On the ninth line, print three "minus" signs.

During the second run, the solution acts as Danila the Magician: given the final state of the board, it has to guess the secret number. The first line contains the word "Danila". The second line contains an integer $t$: the number of test cases, the same as during the first run ($1 \le t \le 1000$). The test cases follow. Each consists of nine lines. The first eight lines contain eight space-separated integers each: the numbers on the board, exactly the same as were printed (each equal to either $0$ or $1$). The ninth line contains three "minus" signs.

To answer a test case, the solution must print one line containing the secret number (an integer from $1$ to $64$).

During each run, each line of input including the last one is terminated by a newline.

예제

On each test, the input during the second run depends on the solution's output during the first run. In the example, we will consider a solution where Danila simply says the sum of all numbers on the board as a guess. And Mia tries to make this sum equal to the secret number. Surely, this solution does not always work.

The two runs of this solution on the first test are shown below.

예제 입력 1

Mia
2
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1
0 1 1 0 1 0 0 1
1 0 0 1 0 1 1 0
1 0 0 1 0 1 1 0
0 1 1 0 1 0 0 1
0 1 1 0 1 0 0 1
1 0 0 1 0 1 1 0
1 0 0 1 0 1 1 0
0 1 1 0 1 0 0 1
31

예제 출력 1

1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
---
0 0 1 0 1 0 0 1
1 0 0 1 0 1 1 0
1 0 0 1 0 1 1 0
0 1 1 0 1 0 0 1
0 1 1 0 1 0 0 1
1 0 0 1 0 1 1 0
1 0 0 1 0 1 1 0
0 1 1 0 1 0 0 1
---

예제 입력 2

Danila
2
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
---
0 0 1 0 1 0 0 1
1 0 0 1 0 1 1 0
1 0 0 1 0 1 1 0
0 1 1 0 1 0 0 1
0 1 1 0 1 0 0 1
1 0 0 1 0 1 1 0
1 0 0 1 0 1 1 0
0 1 1 0 1 0 0 1
---

예제 출력 2

1
31

채점 및 기타 정보

  • 예제는 채점하지 않는다.