import Control.Monad (replicateM,forM_)
import Data.Array (Array,listArray,(!))

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)
                >>= return . listArray ((1,1),(h,w)) . concat
        let (y,x) = solve h w n init
        putStrLn $ unwords $ map show $ [y,x]
        main

solve :: Int -> Int -> Int -> Array (Int,Int) Int -> (Int,Int)
solve h w n init = walk 1 1
    where
    walk y x
        | y == h+1 || x == w+1
            = (y,x)
        | otherwise
            = case (init ! (y,x) + counts ! (y,x)) `mod` 2 of
                0 -> walk (y+1) x
                1 -> walk y (x+1)

    counts = listArray ((1,1),(h,w)) [count y x | y <- [1..h], x<-[1..w]]

    count 1 1 = n - 1
    count y x = (fromNorth y x) + (fromWest y x)

    fromNorth 1 _ = 0
    fromNorth y x = (counts ! (y-1,x) + (1 - init ! (y-1,x))) `div` 2

    fromWest _ 1 = 0
    fromWest y x = (counts ! (y,x-1) + init ! (y,x-1)) `div` 2