#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

#define MAX_N 90
#define MAX_M 90

int m, n;
int field[MAX_N][MAX_M];

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int count_ice(int y, int x) {
	if (field[y][x] == 0) return 0;
	field[y][x] = 0;
	int break_ice = 1;
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (nx < 0 || m <= nx || ny < 0 || n <= ny) continue;
		break_ice = max(break_ice, count_ice(ny, nx)+1);
	}
	field[y][x] = 1;
	return break_ice;
}

int main() {
	while (cin >> m >> n, m || n) {
		for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> field[i][j];

		int break_max = 0;
		for (int i = 0; i < n; i++) 
			for (int j = 0; j < m; j++) 
				break_max = max(break_max, count_ice(i, j));

		cout << break_max << endl;
	}
	return 0;
}