There are 100 bulbs arranged in a 10×10 grid. Pressing the switch of a bulb flips that bulb and the bulbs directly above, below, to the left, and to the right of it. A lit bulb turns off and an unlit bulb turns on. Positions outside the grid are not affected.
Given the initial state of the 100 bulbs, find the smallest number of switch presses that turns every bulb off.
Input
Ten lines are given, each with 10 characters. # is an unlit bulb and O (uppercase letter O) is a lit bulb. No character other than # and O appears in the input.
Output
Print the smallest number of switch presses needed to turn every bulb off, on one line. If turning every bulb off is impossible, print -1.