import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class D {

	public static boolean found = false;
	
	public static void main(String[] args) throws IOException {
		BufferedReader file = new BufferedReader(new InputStreamReader(System.in));
		int inputs = Integer.parseInt(file.readLine());
		while(inputs-->0) {
			StringTokenizer st = new StringTokenizer(file.readLine());
			int rows = Integer.parseInt(st.nextToken());
			int cols = Integer.parseInt(st.nextToken());
			char[][] mat = new char[rows][cols];
			boolean[][] blocked = new boolean[rows][cols];
			for(int r = 0; r < rows; r++) {
				mat[r] = file.readLine().toCharArray();
			}
			for(int r = 0; r < rows; r++) {
				for(int c = 0; c < cols; c++) {
					if(mat[r][c] == '#') {
						blocked[r][c] = true;
					}
					else if(mat[r][c] == 'B') {
						blocked[r][c] = true;
						if(r > 0)
							blocked[r-1][c] = true;
						if(c > 0)
							blocked[r][c-1] = true;
						if(r < rows-1)
							blocked[r+1][c] = true;
						if(c < cols-1)
							blocked[r][c+1] = true;
					}
				}
			}
			boolean pos = true;
			boolean[][] goodPath = new boolean[rows][cols];
			for(int r = 0; r < rows; r++) {
				for(int c = 0; c < cols; c++) {
					if(mat[r][c] == 'G') {
						found = false;
						search(r, c, blocked, new boolean[rows][cols], goodPath);
						if(!found) {
							pos = false;
							break;
						}
					}
				}
			}
			System.out.println(pos ? "Yes" : "No");
		}
		

	}
	
	public static void search(int r, int c, boolean[][] blocked, boolean[][] visited, boolean[][] goodPath) {
		if(r < 0 || c < 0 || r >= blocked.length || c >= blocked[r].length || found)
			return;
		if(visited[r][c])
			return;
		if(goodPath[r][c]) {
			found = true;
			return;
		}
		if(blocked[r][c])
			return;
		visited[r][c] = true;
		goodPath[r][c] = true;
		if(r == blocked.length-1 && c == blocked[r].length-1) {
			found = true;
			return;
		}
		search(r-1, c, blocked, visited, goodPath);
		search(r+1, c, blocked, visited, goodPath);
		search(r, c-1, blocked, visited, goodPath);
		search(r, c+1, blocked, visited, goodPath);
	}

}
