Tic-tac-toe
Peter and Vasylko are playing an intriguing game on a grid of size M×N. They take turns placing either a cross or a nought in the empty cells until the grid is completely filled. Peter's score is calculated by selecting a cell containing a cross, choosing a direction (up, down, left, right, or any diagonal), and counting the number of consecutive cells containing crosses in that direction, including the starting and ending cells. Peter aims to maximize this count. Similarly, Vasyl's score is determined by performing the same process with cells containing noughts.
Your task is to write a program that calculates the final scores for both players.
Input
The first line contains two integers M and N, representing the dimensions of the grid (1 ≤ M, N ≤ 1000). Each of the next M lines contains N integers, each either 0 or 1 (0 indicates a nought in the cell, and 1 indicates a cross).
Output
Output a single line with two integers: the first is Peter's score, and the second is Vasyl's score.