#include<cstdio>
#include<algorithm>
#include<cstring>
#include<functional>
#include<iostream>
#define rep(i,a) for(i=0;i<a;i++)
using namespace std;
int glid[91][91];
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
int m,n,mx,cnt;
void func(int,int);
int main(void)
{
	int i,j,k;
	while(cin>>m>>n && m && n ) {
		mx=-1;
		rep(i,n)rep(j,m) cin>>glid[i][j];
		rep(i,n)rep(j,m) if(glid[i][j]==1) {cnt=0;func(i,j);}
		cout<<mx<<endl;
	}
	return 0;
}
void func(int x,int y)
{
	int i,j,k,xx,yy;
	rep(i,4) {
		xx=dx[i]+x; yy=dy[i]+y;
		if(xx<=m && xx>=0 && yy<=n && yy>=0 && glid[yy][xx]==1) {
			cnt++;
			mx=max(mx,cnt);
			glid[yy][xx]=0;
			func(xx,yy);
			cnt--;
			glid[yy][xx]=1;
		}
	}
}