#include<iostream>
#include<algorithm>
using namespace std;

int n,m;
bool map[90][90];

int backtrack(int h,int w){
  int res = 1,tmp = 1;

  map[h][w] = false;
  if(h>0 && map[h-1][w])tmp = backtrack(h-1,w) + 1;
  res = max(res,tmp);
  if(h<n-1 && map[h+1][w])tmp = backtrack(h+1,w) + 1;
  res = max(res,tmp);
  if(w>0 && map[h][w-1])tmp = backtrack(h,w-1) + 1;
  res = max(res,tmp);
  if(w<m-1 && map[h][w+1])tmp = backtrack(h,w+1) + 1;
  res = max(res,tmp);
  map[h][w] = true;

  return res;
}

int main(){
  int maxim;
  while(1){
    cin >> m;
    cin >> n;
    if(!m && !n)break;

    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++)cin >> map[i][j];
    }
    maxim = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if(map[i][j])maxim = max(maxim,backtrack(i,j));
      }
    }

    cout << maxim << endl;
  }
}