#include<iostream> using namespace std; int a[105][105],f[105][105],r,c; int dx[4]={-1,1,0,0}; int dy[4]={0,0,-1,1}; int dfs(int x,int y){ if(f[x][y] != 0){ return f[x][y]; } f[x][y] = 1; for(int i = 0;i < 4;i++) { int next_x,next_y; next_x = x + dx[i]; next_y = y + dy[i]; if(next_x >= 1&&next_x <= r&&next_y >= 1&&next_y <= c&&a[next_x][next_y] < a[x][y]){ f[x][y] = max(f[x][y],dfs(next_x,next_y) + 1); } } return f[x][y]; } int main(){ int i,j,maxn = -1000000000; cin>>r>>c; for(i = 1;i <= r;i++){ for(j = 1;j <= c;j++){ cin>>a[i][j]; } } for(i = 1;i <= r;i++){ for(j = 1;j <= c;j++){ maxn = max(maxn,dfs(i,j)); } } cout<<maxn<<endl; return 0; }