import java.io.*;
import java.util.*;


public class Main{
    public static char get(char[][] maze, int i, int j){
        if(i>0 && j>0 && i<maze.length && j<maze[0].length)
            return maze[i][j];
        return 0;
    }
    public static boolean solve(char[][] maze){
        int numGood = 0; int numBad = 0;
        for (char[] chars : maze) {
            for (int j = 0; j < maze[0].length; j++) {
                if (chars[j] == 'G')
                    numGood++;
                if (chars[j] == 'B')
                    numBad++;
            }
        }
        if(numGood==0)
            return true;
        int[][] visited = new int[maze.length][maze[0].length];
        DFS(maze, maze.length-1, maze[0].length-1, visited);
        for(int i=0; i<maze.length; i++){
            for(int j=0; j<maze[0].length; j++){
                if(maze[i][j] == 'B'){
                    if(i==maze.length-2&&j==maze[0].length-1)
                        return false;
                    if(i==maze.length-1&&j==maze[0].length-2)
                        return false;
                    char c;
                    c = get(maze, i-1, j);
                    if(c =='R')
                        maze[i-1][j] = '#';
                    if(c=='G')
                        return false;
                    c = get(maze, i, j-1);
                    if( c == 'R')
                        maze[i][j-1] = '#';
                    if(c=='G')
                        return false;
                    c = get(maze, i+1, 1);
                    if(c=='R')
                        maze[i+1][j] = '#';
                    if(c=='G')
                        return false;
                    c = get(maze, i, j+1);
                    if(c== 'R' )
                        maze[i][j+1] = '#';
                    if(c=='G')
                        return false;
                }
            }
        }
        visited = new int[maze.length][maze[0].length];
        return DFSCount(maze, maze.length-1, maze[0].length-1, visited)==numGood;
    }
    public static int DFSCount(char[][] maze, int i, int j, int[][] visited){
        int count = 0;
        if(maze[i][j]=='G')
            count++;
        visited[i][j] = 1;
        if(j>0 && visited[i][j-1]==0 && maze[i][j-1]!='#')
            count+=DFSCount(maze, i, j-1, visited);
        if(i>0 && visited[i-1][j]==0  && maze[i-1][j]!='#')
            count+=DFSCount(maze, i-1, j, visited);
        if(i+1<maze.length && visited[i+1][j] ==0  && maze[i+1][j]!='#')
            count+=DFSCount(maze, i+1, j, visited);
        if(j+1<maze[0].length && visited[i][j+1]==0  && maze[i][j+1]!='#')
            count+=DFSCount(maze, i, j+1, visited);
        return count;
    }
    public static void DFS(char[][] maze, int i, int j, int[][] visited){
        if(maze[i][j]=='.')
            maze[i][j] = 'R';
        visited[i][j] = 1;
        if(j>0 && visited[i][j-1]==0 && maze[i][j-1]!='#')
            DFS(maze, i, j-1, visited);
        if(i>0 && visited[i-1][j]==0  && maze[i-1][j]!='#')
            DFS(maze, i-1, j, visited);
        if(i+1<maze.length && visited[i+1][j] ==0  && maze[i+1][j]!='#')
            DFS(maze, i+1, j, visited);
        if(j+1<maze[0].length && visited[i][j+1]==0  && maze[i][j+1]!='#')
            DFS(maze, i, j+1, visited);
    }
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
    int numTestCases = sc.nextInt();
    for(int ii=0; ii<numTestCases; ii++){
        int n = sc.nextInt();
        int m = sc.nextInt();
        char[][] maze = new char[n][m];
        for(int i=0; i<n; i++){
                maze[i] = sc.nextLine().toCharArray();
        }
        System.out.println(solve(maze)?"Yes":"No");
    }
        // Start writing your solution here. -------------------------------------
   
      /*
      int n      = sc.nextInt();        // read input as integer
      long k     = sc.nextLong();       // read input as long
      double d   = sc.nextDouble();     // read input as double
      String str = sc.next();           // read input as String
      String s   = sc.nextLine();       // read whole line as String

      int result = 3*n;
      out.println(result);                    // print via PrintWriter
      */

        // Stop writing your solution here. -------------------------------------
        out.close();
    }



    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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;
        }

    }
    //--------------------------------------------------------
}