#include #define rep(i, n) for (int i = 0; i < n; ++i) typedef long long ll; using namespace std; int main() { cin.tie(0); ios_base::sync_with_stdio(false); int H, W; cin >> H >> W; vector A(H, vector(W)); rep(i, H) rep(j, W) cin >> A[i][j]; vector dp(H, vector(W, vector(2))); dp[0][0][0] = A[0][0]; rep(i, H) rep(j, W) { if (i + 1 < H) { if (dp[i][j][0] > A[i + 1][j]) dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][0] + A[i + 1][j]); else if (i + 1 != H - 1 && j != W - 1) dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][0]); if (dp[i][j][1] > A[i + 1][j]) dp[i + 1][j][1] = max(dp[i + 1][j][0], dp[i][j][1] + A[i + 1][j]); } if (j + 1 < W) { if (dp[i][j][0] > A[i][j + 1]) dp[i][j + 1][0] = max(dp[i][j + 1][0], dp[i][j][0] + A[i][j + 1]); else if (i != H - 1 && j + 1 != W - 1) dp[i][j + 1][1] = max(dp[i][j + 1][1], dp[i][j][0]); if (dp[i][j][1] > A[i][j + 1]) dp[i][j + 1][1] = max(dp[i][j][0], dp[i][j][1] + A[i][j + 1]); } } if (dp[H - 1][W - 1][0] == 0 && dp[H - 1][W - 1][1] == 0) cout << "No\n"; else cout << "Yes\n"; return 0; }