Electricity saver

Problem description

You are a superintendent in a huge office building. Recently, the price of electricity has grown considerably, so you decided that you need to start saving energy. In order to do that you will have to turn off the lights in all the rooms after people have left the offices.
The room layouts in the building are very regular. Each floor is just divided into MxN rectangular rooms.


When you enter a floor in the evening, some lights might be already turned off, which saves you time. However, you cannot just enter all the rooms, because there might be some top secret corporate documents there, etc. Fortunately, you have access to special "maintenance" light-switches. With them you can turn on/off the lights in any 3x3 room group. Toggling such a switch is equivalent to toggling the light switches in every room in the respective 3x3 group. The way it works is shown below:
The black squares correspond to rooms with the light off. The red square shows a group that is toggled by a switch.
Now, you would like to be able to check if it's possible to turn off all the lights on a single floor. Furthermore, you need to know the minimal number of times you'll have to toggle a switch in order to do that. You decided to write a program that will help you.

Input

At the beginning of the input, there will be a line with a positive integer F that is equal to the number of floors. F descriptions of the floors will follow. Each description will begin with a single line with two space delimited integers M and N. ( 2 < M < 30, 2 < N < 30 )
Then there will be M lines with N digits each that correspond to MxN rooms on the floor. If the light in a room is initially on, the respective character will be a '1', otherwise it will be an '8'.

Output

For each floor, output a line with the minimal number of times you need to toggle a switch to turn off all the lights on the floor. In the case when it is not possible to turn off all the lights, output a line with a single word 'Impossible' (quotes for clarity).

Sample input

3
3 5
11188
11188
11188
4 4
8888
8111
8111
1111
5 6
188188
188811
188188
888888
888111

Sample output

1
Impossible
4