import sys
from math import prod


def generate_ray(origin, direction):
    x, y = origin
    dx, dy = direction

    while True:
        x += dx
        y += dy

        yield x, y


def is_visible(grid, position, direction):
    for destination in generate_ray(position, direction):
        if destination not in grid:
            return True

        if grid[destination] >= grid[position]:
            return False


def get_scenic_score(grid, position, direction):
    for i, destination in enumerate(generate_ray(position, direction)):
        if destination not in grid:
            return i

        if grid[destination] >= grid[position]:
            return i + 1


def main():
    grid = {
        (x, y): int(z_str)
        for y, line in enumerate(sys.stdin)
        for x, z_str in enumerate(line.strip())
    }

    directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]

    print(
        sum(
            any(is_visible(grid, p, d) for d in directions)
            for p in grid
        )
    )

    print(
        max(
            prod(
                get_scenic_score(grid, p, d) for d in directions
            )
            for p in grid
        )
    )


if __name__ == "__main__":
    main()
