#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;

int m, n;
bool grid[90][90];
int dy[4] = {0, -1, 1, 0};
int dx[4] = {-1, 0, 0, 1};
int ans = 0;

void dfs(int y, int x, int cnt) {
	grid[y][x] = false;

	ans = max(ans, cnt);

	rep(i,4) {
		int ny = y + dy[i], nx = x + dx[i];
		if (0 <= ny && ny < n && 0 <= nx && nx < m && grid[ny][nx]) {
			dfs(ny, nx, cnt + 1);
		}
	}

	grid[y][x] = true;
}

signed main()
{
	while (true) {
		cin >> m >> n;
		if (m == 0 && n == 0) break;

		rep(i,n) rep(j,m) cin >> grid[i][j];

		ans = 0;
		rep(i,n) rep(j,m) if (grid[i][j]) {
			dfs(i, j, 1);
		}
		cout << ans << endl;

		/*
		rep(i,n) {
			rep(j,m) {
				if (grid[i][j]) printf("1 ");
				else printf("0 ");
			}
			cout << endl;
		}
		*/
	}
}