#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r" , stdin);
freopen("output.txt", "w" , stdout);
#endif
int T=1;
cin >> T;
while(T--){
ll n,m,k;
cin>>n>>m>>k;
string s[n];
rep(i,n) cin>>s[i];
vector<vector<vector<int> > > dp(n, vector<vector<int> >(m, vector<int>(2,0)));
dp[0][0][1] = dp[0][0][0] = k/2;
if(k&1){
dp[0][0][(int)(s[0][0]-'0')]++;
}
rep(i,n){
rep(j,m){
if(!(i+j)) continue;
int tot = 0;
if(i>0) tot+=dp[i-1][j][1];
if(j>0) tot+=dp[i][j-1][0];
if(j==m-1){
dp[i][j][0]=tot;
if(s[i][j]=='1' && tot>0){
dp[i][j][1]++;
dp[i][j][0]--;
}
}
else if(i==n-1){
dp[i][j][1]=tot;
if(s[i][j]=='0' && tot>0){
dp[i][j][0]++;
dp[i][j][1]--;
}
}
else{
dp[i][j][0] = dp[i][j][1] = tot/2;
if(tot&1){
if(s[i][j]=='1') dp[i][j][1]++;
else dp[i][j][0]++;
}
}
}
}
int x=0, y=0;
while(1){
int tot = dp[x][y][0]+dp[x][y][1];
if(s[x][y]=='1'){
if(tot&1) x++;
else y++;
}
else{
if(tot&1) y++;
else x++;
}
tot = dp[x][y][0]+dp[x][y][1];
if(x==n-1 && y==m-1) break;
if(x==n-1 && (tot>1 || s[x][y]=='1')) break;
if(y==m-1 && (tot>1 || s[x][y]=='0')) break;
}
cout<<x+1<<" "<<y+1<<'\n';
}
cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
return 0;
}