ll@N,@M,@A[N][M],D[M]{},a=0;rep(i,N)a=min[j,0,M](D[j]=min(D[j],a+(i?A[i-1][j]:0))+A[i][j]);wt(N-1?a:0);