Fire!

Write a program that reads a sequence of forests and prints the results
of spreading all the fires of each forest.

Input

Input consists of a sequence of forest descriptions. Each description
consists of a line with n and m (a pair of natural numbers strictly
positive that indicate respectively the number of rows and the number of
columns of the forest), followed by n lines, each one with m characters:
|’A’| for a tree without fire, |’F’| for a tree with fire, and |’.’| for
an empty position.

Output

For each forest of the input, print the result of spread all the fires,
supposing that these are transmitted to the right, to the left, upwards
and downwards, and that the final result of each fire is an empty
position. Print an empty line after each forest.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:45:05.605Z

© Jutge.org, 2006–2026.
https://jutge.org
