// name: queens
import java.io.*;

public class QueensGuide {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    static class TestCase {
        // This is the class that stores the values in an input!
        int rows;
        int cols;
        String[][] board;
    }
    
    // You don't need to do anything here; I've already written it for you! You're welcome
    public static TestCase read() throws java.lang.Exception {
        // Creates a TestCase object to store the inputs
        TestCase testCase = new TestCase();

        // Read in the input and break it up over the x
        // Ex: turns "3x4" into ["3", "4"]
        String[] info = br.readLine().split("x");

        // Turn the string into an integer value
        testCase.rows = Integer.parseInt(info[0]);
        // Turn the string into an integer value
        testCase.cols = Integer.parseInt(info[1]);

        // Create a 2-D array to store the chessboard
        testCase.board = new String[testCase.rows][testCase.cols];
        for (int r = 0; r < testCase.rows; r++) {
            // Read in a row and break it up by character
            // Ex: turns "ABCDE" into ["A", "B", "C", "D", "E"]
            String[] row = br.readLine().split("");
            // Assigns the row into the board, forming the grid one row at a time
            testCase.board[r] = row;
        }

        return testCase;
    }

    public static void logic(TestCase testCase) {
        // rows: A positive integer denoting the number of rows in the chessboard
        // cols: A positive integer denoting the number of columns in the chessboard
        // board: A 2-D array of strings representing the chessboard 
        // board[0][0] will give you the top left character of the chessboard, and 
        // board[2][0] will give you the character two rows down and to the very left
        int rows = testCase.rows;
        int cols = testCase.cols;
        String[][] board = testCase.board;
        // It's your turn to code! Use the variable(s) above to find your answer

        // TODO: YOUR CODE HERE

        return; // Remember to output your solution; replace this line when you're done!
    }

	public static void main(String[] args) throws java.lang.Exception {
        int T = Integer.parseInt(br.readLine());
        for (int i = 0; i < T; i++) {
            logic(read());
            br.readLine(); // Remember the blank line in between test cases!
        }
    }
}