#include<iostream>

#define rep(i,n) for(int i = 1; i <= n; i++)
#define MAX (90)

using namespace std;

int field[MAX+2][MAX+2];
int l;

void search(int y, int x, int hosu)
{
  field[y][x] = 0;
  if(field[y][x+1]){ search(y,x+1,hosu+1); }
  if(field[y][x-1]){ search(y,x-1,hosu+1); }
  if(field[y+1][x]){ search(y+1,x,hosu+1); }
  if(field[y-1][x]){ search(y-1,x,hosu+1); }
  if(hosu > l) l = hosu;
  field[y][x] = 1;
}

int main(void)
{

  int m, n;

  while(cin >> m >> n && m){
    rep(i,n) rep(j,m){
      cin >> field[i][j];
    }
    l = 0;
    rep(i,n) rep(j,m){
      if(field[i][j])
	search(i,j,0);
    }
    cout << l+1 << endl;
  }

  return 0;
}