import scala.io.StdIn.readLine @main def yuki1948(): Unit = val hw = readLine.split(" ").map(_.toInt) val (h, w) = (hw(0), hw(1)) val dp: Array[Array[Array[Long]]] = Array.ofDim[Long](2, 500, 500) val input: Array[Array[Long]] = Array.ofDim[Long](500, 500) for i <- 0 until h do input(i) = readLine().split(" ").map(_.toLong) dp(0)(0)(0) = input(0)(0) for f <- 0 until 2 y <- 0 until h x <- 0 until w do if y < h - 1 then if dp(f)(y)(x) > input(y + 1)(x) && dp(f)(y + 1)(x) < dp(f)(y)(x) + input(y + 1)(x) then dp(f)(y + 1)(x) = dp(f)(y)(x) + input(y + 1)(x) if f == 0 && dp(1)(y + 1)(x) < dp(0)(y)(x) then dp(1)(y + 1)(x) = dp(0)(y)(x) if x < w - 1 then if dp(f)(y)(x) > input(y)(x + 1) && dp(f)(y)(x + 1) < dp(f)(y)(x) + input(y)(x + 1) then dp(f)(y)(x + 1) = dp(f)(y)(x) + input(y)(x + 1) if f == 0 && dp(1)(y)(x + 1) < dp(0)(y)(x) then dp(1)(y)(x + 1) = dp(0)(y)(x) val ans = if (dp(0)(h - 1)(w - 1) + dp(1)(h - 1)(w - 1)) > input(h - 1)(w - 1) then "Yes" else "No" println(ans)