### constant

DIRCS = [[0, 1], [1, 0]]

### main

loop do
  h, w, n = gets.strip.split(' ').map{|s| s.to_i}
  break if (h | w | n) == 0

  crs = h.times.map{gets.strip.split(' ').map{|s| s.to_i}}
  #p crs

  x = y = 0
  n -= 1

  while x < w && y < h
    c = crs[y][x]
    dx, dy = DIRCS[(c + (n & 1)) % 2]
    x += dx
    y += dy

    n >>= 1
  end

  puts [y + 1, x + 1].join(' ')
end