#include using namespace std; using ll = long long; int main(){ ll H, W; cin >> H >> W; vector>> dp(H+1, vector(W+1, vector(2))); vector> A(H+1, vector(W+1, -1)); for (int i=1; i<=H; i++){ for (int j=1; j<=W; j++) cin >> A[i][j]; } for (int i=1; i<=H; i++){ for (int j=1; j<=W; j++){ if (i == 1 && j == 1){ dp[i][j][0] = A[i][j]; continue; } if (i == H && j == W) continue; if (A[i][j] >= dp[i-1][j][0]) dp[i][j][1] = max(dp[i][j][1], dp[i-1][j][0]); if (A[i][j] >= dp[i][j-1][0]) dp[i][j][1] = max(dp[i][j][1], dp[i][j-1][0]); for (int k=0; k<2; k++){ if (A[i][j] < dp[i-1][j][k]) dp[i][j][k] = max(dp[i][j][k], dp[i-1][j][k]+A[i][j]); if (A[i][j] < dp[i][j-1][k]) dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k]+A[i][j]); } } } cout << (max({dp[H][W-1][0], dp[H][W-1][1], dp[H-1][W][0], dp[H-1][W][1]}) > A[H][W] ? "Yes" : "No") << endl; return 0; }