import java.util.Scanner;

public class SolveTheMaze648C {

	public static void main(String[] args) {
		Scanner s =new Scanner(System.in);
		int t = s.nextInt();
		StringBuilder str = new StringBuilder();
		while(t-- > 0) {
			int n = s.nextInt(), m = s.nextInt();
			s.nextLine();
			char arr[][] = new char[n][m];
			int b = 0, g = 0;
			for(int i = 0; i<n;i++) {
				String a = s.nextLine();
				for(int j = 0;j<m;j++) {
					arr[i][j] = a.charAt(j);
					if(arr[i][j] == 'G') g++; 
					if(arr[i][j] == 'B') b++;
				}
			}
			
			
			
			for(int i = 0; i<n;	i++) {
				for(int j = 0;	j<m;	j++) {
					if(arr[i][j] == 'B') {
						
							if(i > 0 && arr[i - 1][j] == '.') arr[i - 1][j] = '#';
							if(j > 0 && arr[i][j - 1] == '.') arr[i][j - 1] = '#';
							if(j < m - 1 && arr[i][j + 1 ] == '.') arr[i][j + 1] = '#';
							if(i < n - 1 && arr[i + 1][j] == '.') arr[i + 1][j] = '#';
						
					}
				}
			}
			
			boolean flag = true;
			for(int i = 0; i<n;	i++) {
				for(int j = 0;	j<m;	j++) {
					if(arr[i][j] == 'G') {
						if((i > 0 && arr[i - 1][j] == 'B') || 
							(j > 0 && arr[i][j - 1] == 'B')  ||
							(j < m - 1 && arr[i][j + 1 ] == 'B') || 
							(i < n - 1 && arr[i + 1][j] == 'B') ) flag = false;
							
							boolean ac = true,bc = true, cc= true,dc = true;
							if(i > 0 && (arr[i - 1][j] == '.' || arr[i - 1][j] == 'G')) ac = false;  
							if(j > 0 && (arr[i][j - 1] == '.'||arr[i][j - 1] == 'G'))  bc = false; 
							if(j < m - 1 && (arr[i][j + 1 ] == '.'||arr[i][j + 1 ] == 'G')) cc = false;
							if(i < n - 1 && (arr[i + 1][j] == '.'||arr[i + 1][j] == 'G')) dc = false;
							
							if(ac && bc && cc && dc)
							flag = false;
						
					}
				}
			}
			if(flag)
			str.append("Yes").append("\n");
			else str.append("No").append("\n");
		}
		System.out.println(str);

	}

}
