import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [h,w] <- getIntList
    as <- concat . zipWith (\f a -> f a) (cycle [id, reverse]) . ind2D <$> replicateM h getIntList
    let ans = reverse . (\(a,_,_) -> a) $ foldl' count ([],True,(0,0)) as
    print $ length ans
    mapM_ putStrLn ans

ind2D as = map (\(i,bs) -> zipWith (\j b -> ((i,j),b)) [1..] bs ) $ zip [1..] as

count (s,e,(i,j)) ((k,l),b)
    | e && even b = (s,True,(k,l))
    | e && odd b = (s,False,(k,l))
    | even b = (p:s,False,(k,l))
    | odd b = (p:s,True,(k,l))
    where p = show i ++ " " ++ show j ++ " " ++ show k ++ " " ++ show l