import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class CF1365D{
    static void dfs(char[][] matrix,int i,int j,int rows,int cols){
        if(matrix[i][j] == 'G'){
            count++;
        }
        matrix[i][j] = 'd';

        if(j+1 <= rows && matrix[i][j+1] != '#' && matrix[i][j+1] != 'd'){
            dfs(matrix,i,j+1,rows,cols);
        }

        if(j-1 >= 1 && matrix[i][j-1] != '#' && matrix[i][j-1] != 'd'){
            dfs(matrix,i,j-1,rows,cols);
        }
        if(i-1 >= 1 && matrix[i-1][j] != '#' && matrix[i-1][j] != 'd'){
            dfs(matrix,i-1,j,rows,cols);
        }
        if(i+1 <= rows && matrix[i+1][j] != '#' && matrix[i+1][j] != 'd'){
            dfs(matrix,i+1,j,rows,cols);
        }

    }





    static int count;
    public static void main(String[] args){
        FastReader input = new FastReader();
        PrintWriter pw = new PrintWriter(System.out);
        // code goes here
        int t = input.nextInt();

        while (t > 0){
            int rows = input.nextInt();
            int cols = input.nextInt();

            char[][] matrix = new char[rows+1][cols+1];

            int countGood = 0;

            for(int i = 1;i <= rows;i++){
                String s = input.nextLine();
                for(int j = 0;j < s.length();j++){
                    matrix[i][j+1] = s.charAt(j);
                    if(matrix[i][j+1] == 'G'){
                        countGood++;
                    }
                }
            }

            for(int i = 1;i <= rows;i++){
                for(int j = 1;j <= cols;j++){
                    if(matrix[i][j] == 'B'){
                        if(i > 1){
                            if(matrix[i-1][j] == '.'){
                                matrix[i-1][j] = '#';
                            }
                        }
                        if(i < rows){
                            if(matrix[i+1][j] == '.'){
                                matrix[i+1][j] = '#';
                            }
                        }
                        if(j > 1){
                            if(matrix[i][j-1] == '.'){
                                matrix[i][j-1] = '#';
                            }
                        }
                        if(j < cols){
                            if(matrix[i][j+1] == '.'){
                                matrix[i][j+1] = '#';
                            }
                        }
                    }
                }
            }


//            for(int i = 1;i <= rows;i++){
//                for(int j = 1;j <= cols;j++){
//                    pw.print(matrix[i][j] + " ");
//                }
//                pw.println();
//            }

            if(countGood == 0){
                pw.println("Yes");
            }

            else if(matrix[rows][cols] == '#' && countGood != 0){
                pw.println("No");
            }
            else{
                int start_i = rows;
                int start_j = cols;
                count = 0;
                dfs(matrix,start_i,start_j,rows,cols);

                if(count == countGood){
                    pw.println("Yes");
                }
                else{
                    pw.println("No");
                }
            }
            t--;
        }



        pw.flush();
        pw.close();
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

}