h, w = read_line.split.map(&.to_i) a = Array.new(h) { read_line.split.map(&.to_i) } dp0 = Array.new(h) { Array.new(w, -1) } dp1 = Array.new(h) { Array.new(w, -1) } dp0[0][0] = a[0][0] h.times do |i| w.times do |j| if j < w - 1 if dp0[i][j] > a[i][j + 1] dp0[i][j + 1] = {dp0[i][j + 1], dp0[i][j] + a[i][j + 1]}.max end if dp1[i][j] > a[i][j + 1] dp1[i][j + 1] = {dp1[i][j + 1], dp1[i][j] + a[i][j + 1]}.max end dp1[i][j + 1] = {dp1[i][j + 1], dp0[i][j]}.max end if i < h - 1 if dp0[i][j] > a[i + 1][j] dp0[i + 1][j] = {dp0[i + 1][j], dp0[i][j] + a[i + 1][j]}.max end if dp1[i][j] > a[i + 1][j] dp1[i + 1][j] = {dp1[i + 1][j], dp1[i][j] + a[i + 1][j]}.max end dp1[i + 1][j] = {dp1[i + 1][j], dp0[i][j]}.max end end end puts [dp0[-1][-1], dp1[-1][-1]].max > a[-1][-1] ? "Yes" : "No"