#include <iostream> #include <stack> #include <cstring> #include <cstdio> using namespace std; const int size = 1000 + 10; int m[size][size]; typedef struct{ int x, y; }P; int pos[8][2] = { 1,0, 0,1, -1,0, 0,-1, 1,1, 1,-1, -1,1, -1,-1 }; int main(){ int M, N; while(scanf("%d,%d", &M, &N) != EOF){ memset(m, 0, sizeof(m)); for(int i=1; i<=M; i++){ for(int j=1; j<N; j++){ scanf("%d,", &m[i][j]); } scanf("%d", &m[i][N]); } int st = 2;//start int now; int maxn = 0; for(int i=1; i<=M; i++) for(int j=1; j<=N; j++){ if(m[i][j] == 1){ P p; p.x = i; p.y = j; stack<P> s; s.push(p); int cnt = 1; while(!s.empty()){ P tp = s.top(); s.pop(); m[tp.x][tp.y] = st; for(int k=0; k<8; k++){ P newp; newp.x = tp.x + pos[k][0]; newp.y = tp.y + pos[k][1]; if(newp.x <=M && newp.x >= 1 && newp.y <=N && newp.y >=1 && m[newp.x][newp.y] == 1){ s.push(newp); m[newp.x][newp.y] = st; cnt++; } } } st++; if(cnt > maxn) maxn = cnt; } } cout << st-2 << "," << maxn << endl; } return 0; }