#include <bits/stdc++.h> using namespace std; int main() { int tt; cin >> tt; while (tt--) { int n, m, k; cin >> n >> m >> k; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } vector<vector<int>> a(n, vector<int>(m)); a[0][0] = k; int x = 0; int y = 0; vector<pair<int, int>> t(n * m); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { t[i * m + j] = make_pair(i, j); } } t.pop_back(); sort(t.begin(), t.end(), [&](pair<int, int> i, pair<int, int> j) { if (i.first + i.second == j.first + j.second) { return i < j; } else { return i.first + i.second < j.first + j.second; } }); for (auto [i, j] : t) { if (a[i][j] == 0) { continue; } if (i == n - 1) { if (s[i][j] == '0') { a[i][j]--; a[i][j + 1]++; if (i == x && j == y && a[i][j] == 0) { y++; } } } else if (j == m - 1) { if (s[i][j] == '1') { a[i][j]--; a[i + 1][j]++; if (i == x && j == y && a[i][j] == 0) { x++; } } } else { if (s[i][j] == '0') { a[i][j + 1] += (a[i][j] + 1) / 2; a[i + 1][j] += a[i][j] / 2; if (i == x && j == y) { if (a[i][j] % 2 == 1) { y++; } else { x++; } } } else { a[i + 1][j] += (a[i][j] + 1) / 2; a[i][j + 1] += a[i][j] / 2; if (i == x && j == y) { if (a[i][j] % 2 == 1) { x++; } else { y++; } } } } } cout << x + 1 << " " << y + 1 << endl; } return 0; }