// package cp;
import java.io.*;
import java.util.*;
public class Cf_three {
	static int cur=0;
	static void bfs_trav(int x,int y,char[][] a,int n,int m){// x means x-coordinate
		Queue<Integer> que_x=new LinkedList<>();
		Queue<Integer> que_y=new LinkedList<>();
		int[][] vis=new int[n][m];
//		int[][] dist=new int[n][n];
		vis[x][y]=1;
		boolean reach_end=false;
		que_x.add(x);
		que_y.add(y);
		int[] dir_1= {-1,1,0,0};
		int[] dir_2= {0,0,-1,1};
		
		while(!que_x.isEmpty()) {
			//System.out.print(que_x.peek()+" "+que_y.peek());
			int v1=que_x.remove();
			int v2=que_y.remove();
//			if(v1==n-1 && v2==n-1) {
//				reach_end=true;
//				break;
//			}
			for (int i = 0; i < 4; i++) {
				if(v1+dir_1[i]>=0 && v1+dir_1[i]<n 
				&& v2+dir_2[i]>=0 && v2+dir_2[i]<m) {
					if(a[v1+dir_1[i]][v2+dir_2[i]]=='#')continue;//1 is obstacle
					if(vis[v1+dir_1[i]][v2+dir_2[i]]==0) {
						vis[v1+dir_1[i]][v2+dir_2[i]]=1;
						if(a[v1+dir_1[i]][v2+dir_2[i]]=='G')cur++;
//						dist[v1+dir_1[i]][v2+dir_2[i]]=dist[v1][v2]+1;
						que_x.add(v1+dir_1[i]);
						que_y.add(v2+dir_2[i]);
					}
				}
			}
		}
//		if(reach_end==true)return dist[n-1][n-1];
//		return (int)Double.POSITIVE_INFINITY; 
	}
	public static void main(String[] args) throws IOException {	
		PrintWriter out = new PrintWriter(System.out);
		Reader.init(System.in);
		Cf_three obj=new Cf_three();
		int t=Reader.nextInt();
		for (int ii = 0; ii < t; ii++) {
			int n=Reader.nextInt();
			int m=Reader.nextInt();
			char[][] a=new char[n][m];
			for (int j = 0; j < n; j++) {
				String str=Reader.next();
				char[] temp=str.toCharArray();
				a[j]=temp;
			}
			int tt=0;
			int tot=0;
//			System.out.println(Arrays.deepToString(a));
//			System.out.println(a[0][1]=='B');
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
//					System.out.println("oh");
					if(a[i][j]=='G')tot++;
					if(a[i][j]=='B') {
//						System.out.println("Helo "+i+" " +" "+j);
						if((i-1)>=0) {
							if(a[i-1][j]=='G') {
								tt=1;
								break;
							}
							if(a[i-1][j]!='B')a[i-1][j]='#';
						}
						if((i+1)<n) {
							if(a[i+1][j]=='G') {
								tt=1;
								break;
							}
							if(a[i+1][j]!='B')a[i+1][j]='#';
						}
						if((j-1)>=0) {
							if(a[i][j-1]=='G') {
								tt=1;
								break;
							}
							if(a[i][j-1]!='B')a[i][j-1]='#';
						}
						if((j+1)<m) {
							if(a[i][j+1]=='G') {
								tt=1;
								break;
							}
							if(a[i][j+1]!='B')a[i][j+1]='#';
						}
					}
				}
			}
			if(tt==1)System.out.println("No");
			else {
				obj.bfs_trav(n-1, m-1, a, n,m);
				if(tot==0)System.out.println("Yes");
				else if(tot!=cur)System.out.println("No");
				else if(a[n-1][m-1]=='#')System.out.println("No");
				else System.out.println("Yes");
//				if(tot==cur)System.out.println("Yes");
//				else System.out.println("No");
			}
			cur=0;
		}
		out.flush();
	}

}
class Reader {

    static BufferedReader reader;

    static StringTokenizer tokenizer;



    /** call this method to initialize reader for InputStream */

    static void init(InputStream input) {

        reader = new BufferedReader(

                     new InputStreamReader(input) );

        tokenizer = new StringTokenizer("");

    }



    /** get next word */

    static String next() throws IOException {

        while ( ! tokenizer.hasMoreTokens() ) {

            //TODO add check for eof if necessary

            tokenizer = new StringTokenizer(

                   reader.readLine() );

        }

        return tokenizer.nextToken();

    }



    static int nextInt() throws IOException {

        return Integer.parseInt( next() );

    }

	

    static double nextDouble() throws IOException {

        return Double.parseDouble( next() );

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

}