eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Letters Q and F

Letters Q and F

Little Lev is learning how to draw letters \t{Q} and \t{F}. Initially, he has a white grid of size $n \times m$. Then he will draw several letters of one of the following two shapes: \begin{center} \includegraphics{pic-0.eps} \end{center} Lev will not rotate or mirror these two shapes. Every time he draws a new letter, he will choose a position for the letter inside the grid and paint all cells of the shape black. Lev will only draw letters in such a way that before drawing all black cells of the letter are white~--- that is, he will never paint a cell twice. You are given the final coloring of the grid. Count the number of letters \t{Q} and letters \t{F} drawn by Lev. \InputFile The first line contains two integers $n$ and $m$~--- the height and the width of the grid ($5 \le n \le 300$; $3 \le m \le 300$). The next $n$ lines contain $m$ characters each, denoting the final state of the grid. A white cell is denoted by `\t{.}', a black cell is denoted by `\t{\#}'. It is guaranteed that the grid is a valid result of Lev's drawing. \OutputFile Print two integers~--- the number of letters \t{Q} and the number of letters \t{F} drawn by Lev, respectively. \Note Illustration for the fourth example test: \begin{center} \includegraphics{pic-1.eps} \end{center}
Ліміт часу 2 секунди
Ліміт використання пам'яті 512 MiB
Вхідні дані #1
5 3
###
#.#
###
..#
..#
Вихідні дані #1
1 0
Вхідні дані #2
5 3
###
#..
##.
#..
#..
Вихідні дані #2
0 1
Вхідні дані #3
5 8
###..###
#.#..#..
###..##.
..#..#..
..#..#..
Вихідні дані #3
1 1
Вхідні дані #4
8 8
.....###
###..#.#
#.######
###.####
#.###.##
#.#.###.
..#...#.
......#.
Вихідні дані #4
2 2
Автор Nikolay Budin