#include<cstdio>
#include<cstring>
using namespace std;

#define rep(i,n) for(i=0; i<n; ++i)

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

void dfs(int x,int y,int crash) {
  if(crash > ans) ans = crash;
  int i;
  rep(i,4) {
    if(x+dx[i] >= 0 && x+dx[i] < n && y+dy[i] >= 0 && y+dy[i] < m) {
      if(area[y+dy[i]][x+dx[i]] == 1) {
	area[y+dy[i]][x+dx[i]] = 0;
	dfs(x+dx[i],y+dy[i], crash+1);
	area[y+dy[i]][x+dx[i]] = 1;
      }
    }
  }
}

int main() {
  int i,j,k;
  while(scanf("%d %d", &n, &m), n|m) {
    memset(area, 0, sizeof(area));
    ans = 0;
    rep(i,m) {
      rep(j,n) {
	scanf("%d", &area[i][j]);
      }
    }

    rep(i,m) {
      rep(j,n) {
	if(area[i][j] == 1) {
	  area[i][j] = 0;
	  dfs(j,i,1);
	  area[i][j] = 1;
	}
      }
    }

    printf("%d\n", ans);
  }
}