#include <bits/stdc++.h>
using namespace std;
const int MX = 2e3 + 5;
int Arr[MX][MX], Sum[MX][MX];
char line[MX];
void process(int r, int c){
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
Sum[i][j] += Sum[i][j - 1] + Arr[i][j];
}
for(int j = 1; j <= c; j++){
Sum[i][j] += Sum[i - 1][j];
}
}
}
int query(int x, int y){
return Sum[x][y];
}
int query(int x1, int y1, int x2, int y2){
int Ans = query(x2, y2);
Ans -= query(x2, y1 - 1);
Ans -= query(x1 - 1, y2);
Ans += query(x1 - 1, y1 - 1);
return Ans;
}
bool func(int r1, int r2, int c, int len){
for(int i = 1, j = len; i <= c; i++, j++){
int num = query(r1, i, r2, j);
if(num == (r2 - r1 + 1) * len) return true;
}
return false;
}
int b_search(int r1, int r2, int c){
int lo = 0, hi = c + 5, mid;
for(; hi - lo > 1 ;){
mid = (hi + lo)/2;
(func(r1, r2, c, mid)) ? lo = mid : hi = mid;
}
return func(r1, r2, c, (hi + lo)/2) * ((hi + lo)/2);
}
int solve(int r, int c){
int Ans = 0;
for(int i = 1; i <= r; i++){
for(int j = i; j <= r; j++){
int len = b_search(i, j, c);
Ans = max(Ans, len * (j - i + 1));
}
}
return Ans;
}
int main(){
int t, r, c;
scanf("%d", &t);
for(int i = 1; i <= t; i++){
scanf("%d %d", &r, &c);
memset(Arr, 0, sizeof(Arr));
memset(Sum, 0, sizeof(Sum));
for(int j = 0; j < r; j++){
scanf("%s", line);
for(int k = 0; k < c; k++){
if(line[k] == '0') Arr[j + 1][k + 1] = 1;
}
}
process(r, c);
int Ans = solve(r, c);
printf("Case %d: %d\n", i, Ans);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgTVggPSAyZTMgKyA1OwppbnQgQXJyW01YXVtNWF0sIFN1bVtNWF1bTVhdOwpjaGFyIGxpbmVbTVhdOwoKdm9pZCBwcm9jZXNzKGludC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