import java.util.Scanner;

public class D_Solve_The_Maze {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-- > 0) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			char [][] maze = new char[n][m];
			for(int i = 0; i < n; i++) {
				String row = sc.next();
				for(int j = 0; j < m; j++) {
					maze[i][j] = row.charAt(j);
				}
			}
			// count good people and build walls around bad people
			int count_g = 0, reach_g = 0;
			boolean neigh = false;
			for(int i = 0; i < n && !neigh; i++) {
				for(int j = 0; j < m; j++) {
					if(maze[i][j] == 'G')
						count_g++;
					else if(maze[i][j] == 'B') {
						if(j != 0) {
							if(maze[i][j - 1] == '.')
								maze[i][j - 1] = '#';
							else if(maze[i][j - 1] == 'G') {
								neigh = true;
								break;
							}
						}
						if(i != 0){
							if(maze[i - 1][j] == '.')
								maze[i - 1][j] = '#';
							else if(maze[i - 1][j] == 'G') {
								neigh = true;
								break;
							}
						}
						if(j != m - 1){
							if(maze[i][j + 1] == '.')
								maze[i][j + 1] = '#';
							else if(maze[i][j + 1] == 'G') {
								neigh = true;
								break;
							}
						}
						if(i != n - 1){
							if(maze[i + 1][j] == '.')
								maze[i + 1][j] = '#';
							else if(maze[i + 1][j] == 'G') {
								neigh = true;
								break;
							}
						}
					}
				}
			}
			// count number of good people who can exit
			if(!neigh)
				reach_g = g_escape(maze, n - 1, m - 1, new boolean[n][m]);
			System.out.println(count_g == reach_g && !neigh? "Yes": "No");
		}
		sc.close();
	}
	public static int g_escape(char[][] maze, int n, int m, boolean[][] V) {
		int count = 0;
		if(n < 0 || m < 0 || n == maze.length || m == maze[0].length || maze[n][m] == '#'|| V[n][m]) return count;
		if(maze[n][m] == 'G') count = 1;
		V[n][m] = true;
		return g_escape(maze, n - 1, m, V) + g_escape(maze, n, m - 1, V) + g_escape(maze, n + 1, m, V) + g_escape(maze, n, m + 1, V) + count;
		
	}

}
