F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Baby Ming and Binary image

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 405    Accepted Submission(s): 155


Problem Description
Baby Ming likes to deal with pixel map in the following way:

First, converting the pixel map into binary image (recorded as 01), and then, in the binary figures, for each grid, add up the grid and its neighboring gridsĄŻ binary number, and store in matrix <b>$Mat$</b>.

All the pictures Baby Ming chosen have a <b>blank upper margin and bottom margin</b> (the value of which is 0 in the binary image), because he thinks such a picture is beautiful.

The matrix $Mat$ is so big that Baby Ming is worried about the mistakes in the matrix. So he wants to know whether the binary image can be regained according to the $Mat$.

 

Input
In the first line contains a single positive integer $T$, indicating number of test case.

In the second line there are two numbers $n, m$, indicating the size of the binary image and the size of the matrix $Mat$

In the next $n$ lines, each line input m numbers, indicating the matrix $Mat$.

$1 \leq T \leq 30, 2 < n \leq 12, m \leq 100$
 

Output
Print <b>Impossible</b>, if it is impossible to regain the binary image.

Print <b>Multiple</b>, if it has more than one result.

Otherwise, print the binary image (Baby Ming's 01 matrix)
 

Sample Input
2 4 4 1 2 3 2 2 3 4 2 2 3 4 2 1 1 1 0 3 1 1 1 0
 

Sample Output
0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 0 Impossible
 

Hint

in the second sample, the matrix[1 0 0] is not Baby Ming's Matrix, so there is no answer
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 21:40:19, Gzip enabled