using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("3 4 3");
WillReturn.Add("1 0 1 1");
WillReturn.Add("0 1 0 0");
WillReturn.Add("1 0 1 0");
WillReturn.Add("0 0 0");
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int[] wkArr = { };
Action<string> SplitAct = pStr =>
wkArr = pStr.Split(' ').Select(pX => int.Parse(pX)).ToArray();
int CurrInd = 0;
while (true) {
SplitAct(InputList[CurrInd]);
int H = wkArr[0];
int W = wkArr[1];
int N = wkArr[2];
if (H == 0 && W == 0 && N == 0) break;
int[,] IntBanArr = CreateBanArr(InputList.Skip(CurrInd + 1).Take(H));
Solve(IntBanArr, N);
CurrInd += 1 + H;
}
}
static void Solve(int[,] pIntBanArr, int pN)
{
int UB_X = pIntBanArr.GetUpperBound(0);
int UB_Y = pIntBanArr.GetUpperBound(1);
char[,] CharBanArr = new char[UB_X + 1, UB_Y + 1];
for (int X = 0; X <= UB_X; X++) {
for (int Y = 0; Y <= UB_Y; Y++) {
if (pIntBanArr[X, Y] == 0) {
CharBanArr[X, Y] = '↓';
}
else {
CharBanArr[X, Y] = '→';
}
}
}
// 配るDPで、マスごとの訪問回数を求める
int[,] VisitCntArr = new int[UB_X + 1, UB_Y + 1];
if (pN >= 2) {
// 左上に配る
VisitCntArr[0, 0] = pN - 1;
// 配るDP
Action<int, int, int> SendAct = (pSendX, pSendY, pSendVal) =>
{
if (UB_X < pSendX) return;
if (UB_Y < pSendY) return;
VisitCntArr[pSendX, pSendY] += pSendVal;
};
for (int X = 0; X <= UB_X; X++) {
for (int Y = 0; Y <= UB_Y; Y++) {
int CurrCnt = VisitCntArr[X, Y];
if (CurrCnt % 2 == 0) {
SendAct(X, Y + 1, CurrCnt / 2);
SendAct(X + 1, Y, CurrCnt / 2);
}
else {
if (CharBanArr[X, Y] == '→') {
SendAct(X + 1, Y, CurrCnt / 2 + 1);
SendAct(X, Y + 1, CurrCnt / 2);
}
else {
SendAct(X + 1, Y, CurrCnt / 2);
SendAct(X, Y + 1, CurrCnt / 2 + 1);
}
}
}
}
}
// 最後の1回をシュミレーションする
int CurrX = 0, CurrY = 0;
while (true) {
if (CurrX > UB_X || CurrY > UB_Y) {
Console.WriteLine("{0} {1}", CurrY + 1, CurrX + 1);
break;
}
char CurrVect = CharBanArr[CurrX, CurrY];
if (VisitCntArr[CurrX, CurrY] % 2 == 1) {
if (CurrVect == '→') {
CurrVect = '↓';
}
else {
CurrVect = '→';
}
}
if (CurrVect == '→') CurrX++;
if (CurrVect == '↓') CurrY++;
}
}
////////////////////////////////////////////////////////////////
// IEnumerable<string>をintの2次元配列に設定する
////////////////////////////////////////////////////////////////
static int[,] CreateBanArr(IEnumerable<string> pStrEnum)
{
var StrList = pStrEnum.ToList();
if (StrList.Count == 0) {
return new int[0, 0];
}
int[] IntArr = { };
Action<string> SplitAct = pStr =>
IntArr = pStr.Split(' ').Select(pX => int.Parse(pX)).ToArray();
SplitAct(StrList[0]);
int UB_X = IntArr.GetUpperBound(0);
int UB_Y = StrList.Count - 1;
int[,] WillReturn = new int[UB_X + 1, UB_Y + 1];
for (int Y = 0; Y <= UB_Y; Y++) {
SplitAct(StrList[Y]);
for (int X = 0; X <= UB_X; X++) {
WillReturn[X, Y] = IntArr[X];
}
}
return WillReturn;
}
}