def occupied(m: list, x, y) -> int:
    """Return 1 if the position (x, y) is occupied, or 0 if it is either outside of the map, or unoccupied."""
    if x == -1 or y == -1 or y == len(m):
        return 0
    if x == len(m[y]):
        return 0
    if m[y][x] == '#':
        return 1
    return 0