import java.util.*;
import java.math.*;
import java.io.*;
public class R648D2D {
		static char[][] grid;
	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
//	 	
 		int t = Integer.parseInt(bf.readLine());
 		for(int i =0;i<t;i++){
 			StringTokenizer st = new StringTokenizer(bf.readLine());
 			int n = Integer.parseInt(st.nextToken());
 			int m = Integer.parseInt(st.nextToken());
 			int numG = 0;
 			grid = new char[n][m];
 			for(int j = 0;j<n;j++){
 				String a = bf.readLine().trim();
 				for(int k = 0;k<m;k++){
 					grid[j][k] = a.charAt(k);
 					if (grid[j][k] == 'G')
 						numG++;
 				}
 				
 			}
 			
 			boolean ans = true;
 			for(int j = 0;j<n;j++){
 				for(int k = 0;k<m;k++){
 					if (grid[j][k] == 'B'){
 						if (j-1 >=0 && grid[j-1][k] == 'G'){
 							ans = false;
 						}
 						else if (j-1 >=0 && grid[j-1][k] == '.'){
 							grid[j-1][k] = '#';
 						}
 						
 						if (k-1 >=0 && grid[j][k-1] == 'G'){
 							ans = false;
 						}
 						else if (k-1 >=0 && grid[j][k-1] == '.'){
 							grid[j][k-1] = '#';
 						}
 						
 						if (j+1 < n && grid[j+1][k] == 'G'){
 							ans = false;
 						}
 						else if (j+1 <n && grid[j+1][k] == '.'){
 							grid[j+1][k] = '#';
 						}
 						
 						if (k+1 < m && grid[j][k+1] == 'G'){
 							ans = false;
 						}
 						else if (k+1 <n && grid[j][k+1] == '.'){
 							grid[j][k+1] = '#';
 						}
 						
 					}
 				}
 				
 			}
 			if (numG == 0){
 				out.println("Yes");
 			}
 			else if (grid[n-1][m-1] == '#'){
 				out.println("No");
 			}
 			else{
 				boolean ans1 = true;
 				floodfill(n-1, m-1, n, m);
 				for(int j = 0;j<n;j++){
 	 				for(int k = 0;k<m;k++){
 	 					if (grid[j][k] == 'G'){
 	 						ans1 = false;
 	 						break;
 	 					}
 	 				}
 	 				if (ans1 == false)
 	 					break;	
 	 			}
 				if (ans1 == true){
 					out.println("Yes");
 				}
 				else{
 					out.println("No");
 				}
 			}
 			
 		}
 		out.close();
 		
 		
 		
	}
	public static void floodfill(int r, int c, int n, int m){
		if (r >=0 && c >=0 && grid[r][c] != '#'){
			grid[r][c] = '.';
			floodfill(r-1, c, n ,m);
			floodfill(r, c-1, n, m);
		}
		
	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	


