Letters Q and F
Time limit2sMemory limit512 MB
Given a final n by m grid where non-overlapping Q and F shapes were painted, count how many of each letter Lev drew.
- Level
Easy3 of 10
- Topics
- Implementation, Matrix
- Solved
- No attempts yet
Statement
Little Lev is learning how to draw the letters Q and F. At first, the grid is a white grid of size . Then Lev draws several letters, each in one of the two shapes below.

Lev does not rotate or mirror these shapes. Each time he draws a letter, he picks a position in the grid and paints all cells of the shape black. He only draws a letter where every cell of the shape is still white, so no cell is ever painted twice.
Given the final coloring of the grid, count the letters Q and the letters F that Lev drew.
Input
The first line contains two integers and , the height and the width of the grid (; ). The next lines each contain characters describing the final state of the grid. A white cell is '.' and a black cell is '\#'.
The grid is guaranteed to be a valid result of Lev's drawing.
Output
Print two integers: the number of letters Q and the number of letters F, in that order.
Hint
The figure below shows the fourth test case.
