#include<iostream>

using namespace std;

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

void search(int x, int y, int count = 1)
{
  ice[x][y] = false;
  for(int i = 0; i < 4; i++)
    if(ice[x + dx[i]][y + dy[i]])
      search(x + dx[i], y + dy[i], count + 1);
    else
      ans = max(count, ans);
  ice[x][y] = true;
  return;
}

int main()
{
  while(cin >> m >> n && (m || n)){

    //part1
    for(int i = 0; i <= n + 1; i++)
      ice[0][i] = ice[m + 1][i] = 0;
    for(int i = 0; i <= m + 1; i++)
      ice[i][0] = ice[n + 1][i] = 0;
    
    for(int i = 1; i <= n; i++)
      for(int j = 1; j <= m; j++)
	cin >> ice[i][j];
    
    //part2
    ans = 0;
    for(int i = 1; i <= n; i++)
      for(int j = 1; j <= m; j++)
	if(ice[i][j])
	  search(i, j);

    cout << ans << endl;
  }
  return 0;
}