Bishop’s Walk

You need to find the best strategy to win a game. In this game, a board is divided into squares arranged in a square grid (like a chessboard, but the number of squares may be different from 64). Each square has a number between 0 and 9 in it, which indicates its value. A chess bishop starts in a given square and you have to move it a number of times (l) diagonally (as in chess, it should move the same distance vertically and horizontally). Each time, you win the number of points of the destination square. For example, for the following board: Starting at the circled square and with 4 moves, the blue path earns 17 points. On the other hand, the green path obtains 36 points, which is the maximum in this case. The program will receive the size of the board, the number of moves (l), and the coordinates of the starting square. It should calculate the maximum number of points that can be won from the starting square in l moves. Input The input format is as follows: An integer in a single line which says the number of problems to solve. Then, for each problem: • Two integers in a line separated by a space indicating the width of the board (n) and the number of moves (l). The height of the board is always the same as its width. • Two integers in a line separated by a space indicating the horizontal and vertical coordinates, respectively, of the starting square. Coordinates start at 0 at the top left corner and increase rightwards and downwards. • n rows of n numbers each indicating the value of each square. Both n and l are less or equal than 50.

2/2 Output For each problem, a line with a single number indicating the maximum amount of points that can be obtained doing l moves starting from the given square. Sample Input 1 84 65 10372546 35996716 01181411 92586265 49275748 23890950 16830040 29982537 Sample Output 36