import java.io.*;
import java.util.*;
import java.math.*;

public class E {

	public void realMain() throws Exception {

		BufferedReader fin = new BufferedReader(new InputStreamReader(System.in), 1000000);

		String in = fin.readLine();

		String[] ar = in.split(" ");

		int T = Integer.parseInt(ar[0]);
	for(int t = 0; t < T; t++) {
		in = fin.readLine();
		ar = in.split(" ");
		
		int n = Integer.parseInt(ar[0]);
		int m = Integer.parseInt(ar[1]);

		char[][] grid = new char[n][m];

		for(int i = 0; i < n; i++) {
			in = fin.readLine();
			for(int j = 0; j < m; j++) {
				grid[i][j] = in.charAt(j);
			}
		}

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				if(grid[i][j] == 'B') {
					if(i > 0) {
						if(grid[i - 1][j] == '.') {
							grid[i - 1][j] = '#';
						}
					}
					if(i < n - 1) {
						if(grid[i + 1][j] == '.') {
							grid[i + 1][j] = '#';
						}
					}
					if(j > 0) {
						if(grid[i][j - 1] == '.') {
							grid[i][j - 1] = '#';
						}
					}
					if(j < m - 1) {
						if(grid[i][j + 1] == '.') {
							grid[i][j + 1] = '#';
						}
					}
				}
			}
		}

		boolean can = true;

		boolean[][] aafg = new boolean[n][m];


		//for all good...need to see if they can reach the end...
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				if(grid[i][j] == 'G' && !aafg[i][j]) {
					boolean[][] reached = new boolean[n][m];

					ArrayList<Integer> xcoord = new ArrayList<Integer>();
					ArrayList<Integer> ycoord = new ArrayList<Integer>();

					xcoord.add(i);
					ycoord.add(j);
			
					reached[i][j] = true;

					int ind = 0;

					while(ind < xcoord.size()) {
						int x = xcoord.get(ind);
						int y = ycoord.get(ind);
						ind++;

						/*if(reached[x][y]) {
							continue;
						}*/

						if(x > 0) {
							if(!reached[x - 1][y] && grid[x - 1][y] != '#') {
								xcoord.add(x - 1);
								ycoord.add(y);
								reached[x - 1][y] = true;
								aafg[x - 1][y] = true;
							}
						}

						if(x < n - 1) {
							if(!reached[x + 1][y] && grid[x + 1][y] != '#') {
								xcoord.add(x + 1);
								ycoord.add(y);
								reached[x + 1][y] = true;
								aafg[x + 1][y] = true;
							}
						}

						if(y > 0) {
							if(!reached[x][y - 1] && grid[x][y - 1] != '#') {
								xcoord.add(x);
								ycoord.add(y - 1);
								reached[x][y - 1] = true;
								aafg[x][y - 1] = true;
							}
						}

						if(y < m - 1) {
							if(!reached[x][y + 1] && grid[x][y + 1] != '#') {
								xcoord.add(x);
								ycoord.add(y + 1);
								reached[x][y + 1] = true;
								aafg[x][y + 1] = true;
							}
						}
					}

					if(!reached[n - 1][m - 1]) {
						can = false;
					}
				}
			}
		}

		boolean[][] aafb = new boolean[n][m];

		//for all bad...need to see if they can reach the end...
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				if(grid[i][j] == 'B' && !aafb[i][j]) {
					boolean[][] reached = new boolean[n][m];

					ArrayList<Integer> xcoord = new ArrayList<Integer>();
					ArrayList<Integer> ycoord = new ArrayList<Integer>();

					xcoord.add(i);
					ycoord.add(j);
			
					reached[i][j] = true;

					int ind = 0;

					while(ind < xcoord.size()) {
						int x = xcoord.get(ind);
						int y = ycoord.get(ind);
						ind++;

						/*if(reached[x][y]) {
							continue;
						}*/

						if(x > 0) {
							if(!reached[x - 1][y] && grid[x - 1][y] != '#') {
								xcoord.add(x - 1);
								ycoord.add(y);
								reached[x - 1][y] = true;
								aafb[x - 1][y] = true;
							}
						}

						if(x < n - 1) {
							if(!reached[x + 1][y] && grid[x + 1][y] != '#') {
								xcoord.add(x + 1);
								ycoord.add(y);
								reached[x + 1][y] = true;
								aafb[x + 1][y] = true;
							}
						}

						if(y > 0) {
							if(!reached[x][y - 1] && grid[x][y - 1] != '#') {
								xcoord.add(x);
								ycoord.add(y - 1);
								reached[x][y - 1] = true;
								aafb[x][y - 1] = true;
							}
						}

						if(y < m - 1) {
							if(!reached[x][y + 1] && grid[x][y + 1] != '#') {
								xcoord.add(x);
								ycoord.add(y + 1);
								reached[x][y + 1] = true;
								aafb[x][y + 1] = true;
							}
						}
					}

					if(reached[n - 1][m - 1]) {
						can = false;
					}
				}
			}
		}

		if(can) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}


	}

	}


	public static void main(String[] args) throws Exception {
		E e = new E();
		e.realMain();
	}
}