Submit solution

Points:
7

Time limit:
2.0s

Python 3
5.0s

Memory limit:
128M

Python 3
128M

Authors:

Problem type

Henry Two has been working on a GPS system for the school itself, and after years of hard work, he realized that what he was making already existed. Therefore he needs to make his better. Given someones room numbers, and assuming they start at room 1, find out which rooms they are able to go to, assuming the user can only move up, down, left, and right.

#### Input Specifications

First, two numbers, and representing the width and height respectively . Then, a grid, where `#`

represents a wall, `O`

represents an empty space, and a number will represent a room. There will be no more than rooms.

#### Output Specifications

The list of rooms the user is able to travel to (Including room ) separated by spaces from least to greatest.

#### 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