#include <iostream>
using namespace std;
int sun = 0;
int arr[20][20];
int mmax=0;
int x, y;
void check(int a,int b){
int sum = 0;
for (int i = a; i < a+y; i++) {
for (int j = b; j < b+y; j++) {
sum += arr[i][j];
}
}
if (mmax < sum) {
mmax = sum;
}
}
void run() {
sun++;
mmax = 0;
cin >> x >> y;
for (int i = 0; i < x; i++) {
for (int j = 0; j < x; j++) {
cin >> arr[i][j];
}
}
for (int i = 0; i < x-(y-1); i++) {
for (int j = 0; j < x - (y-1); j++) {
check(i,j);
}
}
cout << "#" << sun << " " << mmax <<"\n";
}
int main() {
int n = 0;
cin >> n;
for (int i = 0; i < n; i++) {
run();
}
return 0;
}