Cross Flip

No attempts yetTime limit1sMemory limit256 MB

Problem

You are given a 3x3 board. Each square starts out white or black. When you click a square, that square and the squares next to it to the north, south, east, and west (the ones that exist on the board) flip color: white becomes black, and black becomes white.

You want to turn an all-white 3x3 board into the board given in the input. You cannot rotate the board.

Input

The first line has the number of test cases PP (0<P500 < P \le 50).

Each test case is three lines of three characters. * means black and . means white.

Output

For each test case, print the minimum number of clicks needed to turn the all-white board into the board given in the input, one answer per line.