Henry Two had been working on a GPS system for the school itself, and after years of hard work, he realizes that what he had been making already exists. Therefore, he needs to make his better. Given an
Input Specification
The first line will contain the integer
The second line will contain the integer
The next #
represents a wall, O
represents an empty space, and a number will represent a room. There will be no more than
Output Specification
Output the list of room numbers Henry is able to travel to (including room
Sample Input 1
5
4
O3OO2
OOOO#
1###4
#5OOO
Sample Output 1
1 2 3
Sample Input 2
7
8
OOO#2O#
1OOOO#3
OOOOOO#
OOO7OOO
OOOOOOO
##OOO#O
O4#O#5O
6O#OOOO
Sample Output 2
1 2 5 7
Comments