import Control.Applicative ((<$>), (<*>))
import Control.Monad (replicateM)
import Data.Bool (bool)
import Data.List (intercalate, foldl')
import Data.Char (digitToInt)
import Data.Vector.Unboxed (Vector, (!))
import qualified Data.Vector.Unboxed as V
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS

main :: IO ()
main = do
  [h, w] <- f
  solve h w <$> f <*> replicateM h (map digitToInt <$> getLine) >>= putStrLn
    where f = map read <$> words <$> getLine

solve :: Int -> Int -> [Int] -> [[Int]] -> String
solve h w [sx, sy, gx, gy] ms = bool "NO" "YES" . (IS.member (toIx (gx-1) (gy-1))) $ dfs w IS.empty (toIx (sx-1) (sy-1))
  where
    mv = V.fromList $ replicate (w+1) 100 ++ intercalate [100] ms ++ replicate (w+1) 100
    toIx i j = (i+1)*(w+1)+j
    dfs w mm cp = foldl' (dfs w) (IS.insert cp mm) np
      where np = [tp | tp <- [cp+1, cp-w-1, cp-1, cp+w+1], abs ((mv ! tp) - cph) <= 1, IS.notMember tp mm] ++
                 [tp2 | (tp1, tp2) <- [(cp+1, cp+2), (cp-w-1, cp-2*w-2), (cp-1, cp-2), (cp+w+1, cp+2*w+2)], (mv ! tp1) < cph, (mv ! tp2) == cph, IS.notMember tp2 mm]
            cph = mv ! cp