#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int T;
cin >> T;
while(T--) {
int n, m;
cin >> n >> m;
vector<vector<char>> a(n, vector<char>(m));
int sx, sy;
for(int i = 0; i < n