#include <math.h>
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int a[92][92] = {0};
int m;
int n;

int kansu( int x, int y, int c, int s ) {
	a[x][y] = 0;
	s = max( s, c );
	if ( a[x+1][y] == 1 ) {
		s = kansu( x+1, y, c+1, s );
	}
	if ( a[x-1][y] == 1 ) {
		s = kansu( x-1, y, c+1, s );
	}
	if ( a[x][y+1] == 1 ) {
		s = kansu( x, y+1, c+1, s );
	}
	if ( a[x][y-1] == 1 ) {
		s = kansu( x, y-1, c+1, s );
	}
	a[x][y] = 1;
	return s;
}

int main(){
	while(true) {
		cin >> m >> n;
		if ( m == 0 ) break;
		for ( int i = 0; i < n+2; i++ ) {
			for ( int j = 0; j < m+2; j++ ) {
				if ( i == 0 || i == n+1 || j == 0 || j == m+1 ) {
					a[j][i]=0;
				}else {
					cin >> a[j][i];
				}
			}
		}
		int s = 0;
		for ( int i = 1; i < n+1; i++ ) {
			for ( int j = 1; j < m+1; j++ ) {
				if ( a[j][i]==1 ) s = max( s, kansu( j, i, 1, s ) );
			}
		}
		cout << s << endl;
	}
	return 0;
}