#include #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) #define rep(i, n) for(int i=0;i> h >> w; vector dp(h, vector(w, vector(2, -1LL))); rep(i, h) rep(j, w) { ll a; cin >> a; if(i == j && i == 0) { dp[i][j][0] = a; continue; } if(i == 0) { rep(k, 2) { if(dp[i][j - 1][k] > a) { dp[i][j][k] = dp[i][j - 1][k] + a; } if(k == 0) chmax(dp[i][j][1], dp[i][j-1][0]); } continue; } if(j == 0) { rep(k, 2) { if(dp[i - 1][j][k] > a) { dp[i][j][k] = dp[i - 1][j][k] + a; } if(k == 0) chmax(dp[i][j][1], dp[i-1][j][0]); } continue; } rep(k, 2) { if(dp[i - 1][j][k] > a) chmax(dp[i][j][k], dp[i - 1][j][k] + a); if(dp[i][j - 1][k] > a) chmax(dp[i][j][k], dp[i][j - 1][k] + a); } if(i == h - 1 && j == w - 1) continue; chmax(dp[i][j][1], dp[i][j-1][0]); chmax(dp[i][j][1], dp[i-1][j][0]); } cout << (dp[h - 1][w - 1][0] == -1 && dp[h - 1][w - 1][1] == -1 ? "No" : "Yes") << endl; return 0; }