import java.util.Scanner;

public class p4 {
	static char[][] maze;
	static boolean[][] ffd;
	static boolean[][] bpffvis;
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int t = in.nextInt();
		tcase:
		for (int ti = 0; ti < t; ti++) {
			int n = in.nextInt(), m = in.nextInt();
			maze = new char[n][m];
			for (int i = 0; i < n; i++) {
				String ln = in.next();
				maze[i] = ln.toCharArray();
			}
			
			ffd = new boolean[n][m];
			ff(n-1, m-1);
			if (!checkgp()) {
				System.out.println("No");
				continue tcase;
			}
			
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (maze[i][j] == 'B' && ffd[i][j]) {
						bpffvis = new boolean[n][m];
						bpff(i, j);
						ffd = new boolean[n][m];
						ff(n-1, m-1);
						if (ffd[i][j] || !checkgp()) {
							System.out.println("No");
							continue tcase;
						}
					}
				}
			}
			
			System.out.println("Yes");
		}
		in.close();

		
		
	}
	
	static void bpff(int i, int j) {
		bpffvis[i][j] = true;
		for (int d = 0; d < 4; d++) {
			int ni = i+dx[d];
			int nj = j+dy[d];
			if (ni >= 0 && ni < maze.length && nj >= 0 && nj < maze[0].length && maze[ni][nj] != '#') {
				if (maze[ni][nj] == '.') {
					maze[ni][nj] = '#';
				} else if (!bpffvis[ni][nj]) {
					bpff(ni, nj);
				}
			}
		}
	}
	
	static int[] dx = {-1, 0, 1, 0};
	static int[] dy = {0, 1, 0, -1};
	static void ff(int i, int j) {
		if (maze[i][j] == '#') return;
		ffd[i][j] = true;
		for (int d = 0; d < 4; d++) {
			int ni = i+dx[d];
			int nj = j+dy[d];
			if (ni >= 0 && ni < maze.length && nj >= 0 && nj < maze[0].length && !ffd[ni][nj] && maze[ni][nj] != '#') {
				ff(ni, nj);
			}
		}
	}
	
	static boolean checkgp() {
		for (int i = 0; i < maze.length; i++) {
			for (int j = 0; j < maze[i].length; j++) {
				if (maze[i][j] == 'G' && !ffd[i][j]) return false;
			}
		}
		return true;
	}
}
