#include <vector>
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
vector<pair<int, int>> moves = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int tt;
cin >> tt;
for (int tc = 1; tc <= tt; tc++) {
cout << "Floor #" << tc << ": ";
int n, m;
cin >> n >> m;
vector<string> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int ans = 0;
vector was(n, vector<bool> (m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (!was[i][j] && a[i][j] - '1') {
was[i][j] = 1;
vector<int> que(1, i * m + j);
for (int k = 0; k < (int) que.size(); k++) {
int x = que[k] / m;
int y = que[k] % m;
for (auto [u, v] : moves) {
u += x, v += y;
if (min(u, v) >= 0 && min(n - u, m - v) > 0 && a[u][v] - '1' && !was[u][v]) {
was[u][v] = 1;
que.push_back(u * m + v);
}
}
}
ans = max(ans, (int) que.size());
}
}
}
cout << ans << '\n';
}
return 0;
}