Suki's Garden Visibility
Suki, a black curly-coated dog with a grey beard and white paws, is standing somewhere in her rectangular garden. The garden contains trees at various heights. From where she stands, Suki looks outward in each of the 8 compass directions (north, south, east, west, and the four diagonals) and counts how many trees she can see in each direction. A tree blocks her view of any tree directly behind it that is not strictly taller.
Input
The first line contains n and m (1 ≤ n, m ≤ 500), the dimensions of the garden grid.
The next n lines each contain m positive integers, the heights of the trees in the garden (1 ≤ height ≤ 10^9).
The next line contains two integers r and c (0 ≤ r < n, 0 ≤ c < m), Suki's position (0-indexed row and column).
Output
Print 8 integers on a single line, separated by spaces: the number of visible trees in each direction in this order: North, South, East, West, NorthEast, NorthWest, SouthEast, SouthWest.
Notes
A tree is visible from Suki's position in a direction if it is strictly taller than every tree between Suki and it in that direction. Shorter trees are hidden, but they don't end the ray: a taller tree further out is still visible.