import java.util.Scanner;

public class Contest648D {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0){
            int m=sc.nextInt();
            int n=sc.nextInt();

            char[][] A=new char[m][n];
            for(int i=0;i<m;i++){
                char[] ch=sc.next().toCharArray();
                A[i]=ch;
            }
            if(m==1 && n==1){
                System.out.println("Yes");
                continue;
            }
            int[][] visited=new int[m][n];
            for(int i=0;i<m;i++){
                for(int j=0;j<n;j++){
                    if(A[i][j]=='#' || A[i][j]=='B')
                        visited[i][j]=-1;
                    if(A[i][j]=='B'){
                        if(i-1>=0 && A[i-1][j]!='G'){
                            A[i-1][j]='#';
                            visited[i-1][j]=-1;
                        }
                        if(i+1<m && A[i+1][j]!='G'){
                            A[i+1][j]='#';
                            visited[i+1][j]=-1;
                        }
                        if(j-1>=0 && A[i][j-1]!='G'){
                            A[i][j-1]='#';
                            visited[i][j-1]=-1;
                        }
                        if(j+1<n && A[i][j+1]!='G'){
                            A[i][j+1]='#';
                            visited[i][j+1]=-1;
                        }
                    }
                }
            }
            for(int i=0;i<m;i++){
                for(int j=0;j<n;j++){
                    if(A[i][j]=='G' && visited[i][j]!=2){
                       dfs(A,m,n,i,j,visited);
                    }
                }
            }
            boolean flag=true;
            for(int i=0;i<m;i++){
                for(int j=0;j<n;j++){
                    if(A[i][j]=='G'){
                        if(visited[i][j]!=2){
                            flag=false;
                            break;
                        }
                    }
                }
                if(!flag) break;
            }
            if(flag){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }

        }
    }
    public static int dfs(char[][] A,int m,int n,int row,int col,int[][] visited){

        if(row<0 || row>=m || col<0 || col>=n || visited[row][col]==-1 || visited[row][col]==1)
            return -1;
        if(visited[row][col]==2) return 2;
        if(row==m-1 && col==n-1){
            visited[row][col]=2;
            return 2;
        }
        visited[row][col]=1;
        visited[row][col]=Math.max(visited[row][col],Math.max(dfs(A,m,n,row-1,col,visited),dfs(A,m,n,row,col-1,visited)));
        visited[row][col]=Math.max(visited[row][col],dfs(A,m,n,row+1,col,visited));
        visited[row][col]=Math.max(visited[row][col],dfs(A,m,n,row,col+1,visited));
        return visited[row][col];

    }
}
