import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int t=scn.nextInt();
		while(t-->0){
			int n=scn.nextInt();
			int m=scn.nextInt();
			char [][]arr =new char[n][m];
			scn.nextLine();
		   for(int i=0;i<arr.length;i++){
			   String s=scn.next();
			    arr[i]=s.toCharArray();
		   }
		   int cnt=0;
		   for(int i=0;i<arr.length;i++){
			   for(int j=0;j<m;j++){
				   if(arr[i][j]=='G'){
					   cnt++;
				   }
			   }
			  // System.out.println();
		   }
		   if(arr[arr.length-1][arr[0].length-1]=='b'){
			   System.out.println("No");
			   continue;
		   }
		   if(cnt==0){
			   System.out.println("Yes");
			   continue;
		   }
		   boolean f=false;
		   int []r = {1,-1,0,0};
			int []c = {0,0,-1,1};
		  for(int i=0;i<arr.length;i++){
			  for(int j=0;j<arr[0].length;j++){
				  if(arr[i][j]=='B'){
					 for(int k=0;k<4;k++){
						 int nr = i+r[k];
						 int nc = j+c[k];
						 if(check(arr,nr,nc)){
							 if(arr[nr][nc]=='G'|| (nr==arr.length-1 && nc==arr[0].length)){
								 f=true;
								 break;
							 }
							 if(arr[nr][nc]=='.')
							 arr[nr][nc]='#';
						 }
					 }
				  }
			  }
			  if(f){
				  break;
			  }
		  }
		  if(f){
			  System.out.println("No");
			  continue;
		  }
		  
		  boolean f1=false;
		  for(int i=0;i<n;i++){
			  for(int j=0;j<m;j++){
				  if(arr[i][j]=='G'){
					  f=true;
					 f1=check1(arr,i,j,cnt);
					 break;
				  }
			  }
			  if(f){
				  break;
			  }
		  }
		  if(f1){
			  System.out.println("Yes");
			  continue;
		  }
		  System.out.println("No");
		  
		}

	}
	public static boolean check1(char [][]arr , int i ,int j, int cnt){
		int[][]arr1 =new int[arr.length][arr[0].length];
		LinkedList<pair>q=new LinkedList<>();
		int count=0;
		int []r = {1,-1,0,0};
		int []c = {0,0,-1,1};
		q.addLast(new pair(i,j));
		boolean flag=false;
		while(q.size()>0){
			pair p =q.removeFirst();
			if(p.r==arr.length-1 && p.c==arr[0].length-1){
			flag=true;
			}
			if(arr1[p.r][p.c]==1){
				continue;
			}
			if(arr[p.r][p.c]=='G'){
				count++;
			}
			arr1[p.r][p.c]=1;
			for(int k=0;k<4;k++){
				int nr = p.r+r[k];
				int nc = p.c+c[k];
				if(check(arr,nr,nc)){
					q.addLast(new pair(nr ,nc));
				}
				}
		}
		//System.out.print(count+"A"+flag+"c"+cnt);
		if(flag&& count==cnt){
			return true;
		}else{
			return false;
		}
		
	}
	
	public static boolean check(char [][]arr ,int i ,int j){
		if(i>=arr.length || i<0 || j>=arr[0].length || j<0  || arr[i][j]=='#'){
			return false;
		}
		return true;
	}
	
	public static class pair{
		int r;
		int c;
		public pair(int i,int j){
			this.r=i;
			this.c=j;
		}
	}

}