write the program for the below given data
Sean invented a game involving a 2n * 2n matrix where each cell of the matrix contains an integer. He can reverse any of its rows or columns any number of times, and the goal of the game is to maximize the sum of the elements in the n * n submatrix located in the upper-left corner of the 2n * 2n matrix (i.e., its upper-left quadrant).
Given the initial configurations for q matrices, help Sean reverse the rows and columns of each matrix in the best possible way so that the sum of the elements in the matrix’s upper-left quadrant is maximal. For each matrix, print the maximized sum on a new line.