#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include using namespace std; ll dp[900][900]; const ll INF=2e18; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int h,w; cin>>h>>w; vector> A(h-2,vector(w)); rep(i,h-2) rep(j,w) cin>>A[i][j]; rep(i,900) rep(j,900) dp[i][j]=INF; rep(i,h-2) if(A[i][0]!=-1) dp[i][0]=A[i][0]; for(int j=1;j