import Control.Monad (replicateM,forM_)
import Control.Monad.ST (ST,runST)
import qualified Data.Array.ST as STArr

main = do
    [h,w,n] <- getLine >>= return . map read . words
    if all (==0) [h,w,n] then return () else do
        init <- replicateM h (getLine >>= return . map read . words)
        let (y,x) = solve h w n init
        putStrLn $ unwords $ map show $ [y,x]
        main

solve :: Int -> Int -> Int -> [[Int]] -> (Int,Int)
solve h w n init = runST $ do
    table <- STArr.newListArray ((1,1),(h,w)) (concat init)
            :: ST s (STArr.STArray s (Int,Int) Int)
    forM_ [1..n-1] (\_ -> walk table (1,1))
    walk table (1,1)

    where
    walk table (y,x) = do
        dir <- STArr.readArray table (y,x)
        STArr.writeArray table (y,x) (1-dir)
        let (y',x') = if dir == 0 then (y+1,x) else (y,x+1)
        if y' == h+1 || x' == w+1
            then return (y',x')
            else walk table (y',x')
        