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++;
				}
			}
			
			if(g == 0 ) {
				str.append("Yes").append("\n");
				continue;
			}
			boolean ans = true;
			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] = '#';
							else if(i > 0 && arr[i - 1][j] == 'G') ans = false;
							
							if(j > 0 && arr[i][j - 1] == '.') arr[i][j - 1] = '#';
							else if(j > 0 && arr[i][j - 1] == '.') ans =false;
							
							if(j < m - 1 && arr[i][j + 1 ] == '.') arr[i][j + 1] = '#';
							else if(j < m - 1 && arr[i][j + 1 ] == 'G') ans =false;
							
							if(i < n - 1 && arr[i + 1][j] == '.') arr[i + 1][j] = '#';
							else if(i < n - 1 && arr[i + 1][j] == 'G') ans =false;
						
					}
				}
			}
		
			boolean visited[][] = new boolean[n][m];
			if(arr[n -1][m - 1] =='.')
			dfs(arr,n - 1,m - 1,visited,n,m);
			else ans = false;
			
			for(int i = 0;i<n;i++ ) {
				for(int j = 0;j<m;j++) {
					if(arr[i][j] == 'G' && !visited[i][j]) {
						ans = false;
					}
				}
			}
			
			
			
			if(ans)
			str.append("Yes").append("\n");
			else str.append("No").append("\n");
		}
		System.out.println(str);

	}

	private static void dfs(char[][] arr, int i, int j, boolean[][] visited, int n, int m) {
			
		visited[i][j] = true;
		if(i > 0 && (arr[i - 1][j] == '.' || arr[i - 1][j] == 'G') && !visited[i - 1][j]) dfs(arr, i - 1, j, visited, n, m);
		
		
		if(j > 0 && (arr[i][j - 1] == '.' || arr[i][j - 1] == 'G') && !visited[i][j - 1]) dfs(arr, i, j - 1, visited, n, m);
		
		
		if(j < m - 1 && (arr[i][j + 1 ] == '.' || arr[i][j + 1 ] =='G') &&  !visited[i][j + 1]) dfs(arr, i, j + 1, visited, n, m);
		
		
		if(i < n - 1 && (arr[i + 1][j] == '.' || arr[i + 1][j] =='G') && !visited[i + 1][j]) dfs(arr, i + 1, j, visited, n, m);
		
			
	}

}
