Kiano The Clause!

So Kiano’s child Riano likes her father’s long beard. She started calling him Candy Clause because this tall and bearded person likes to play Candy Crush and looks like angry Santa Clause. One day, Kiano, bored with easy challenges (!) of Candy Crush started a new and simple game with Fallen. Fallen and Kiano start playing on an N × 5 board, called the game board. Initially all the cells of the board contains 0. Then they ask Riano, the judge of the game, to show them an interesting board. Riano sets an M × 5 board that is divided into M rows and 5 columns called interesting board. Each of the cells of the interesting board contains either 0 or 1. Now in his only turn, Fallen can change any number of 0’s to 1’s on the game board. After Fallen’s move, Kiano, in his only turn, can change any number of 1’s to 0’s on the game board. If Kiano can make any M × 5 sub board exactly the same as the interesting board set by the honorable judge Riano, Kiano wins. Otherwise Fallen gets the point equal to number of cells he changed in his turn. Fallen wants to win the game at any cost and he also wants to win as many points as possible. Print the maximum possible point Fallen can win. If Fallen loses the game, print -1 instead. Input The first line of the input contains an integer T (T ≤ 50) denoting the number of test cases. Each of the following T cases starts with a pair of positive integers N and M, where N is the number of rows of the game board and M is the number of rows of the interesting board set by Riano. N and M are separated by space. Following this line there will be exactly M lines, each having 5 digits, ‘0’ or ‘1’ describing the board set by Riano. Note that, 1 ≤ M ≤ 15, 1 ≤ N ≤ 50, M ≤ N. Please note that for 90% of the cases, M ≤ 5. Output For each input, print the output in the format, ‘Case X: Y ’ here Y is the maximum number of point Fallen will win. If no matter how Fallen plays, he loses always print ‘-1’. Sample Input 3 11 11111 22 11111 11111 33 10111 11001 11111 Sample Output Case 1: 4 Case 2: 9 Case 3: 14